Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Monday, April 14, 2014

Delete System Files On Windows 7

On Windows 7, system file are protected from being deleted. The following commands can be used to delete system files.

set THE_FILE_TO_DELETE=C:\Windows\IME\IMESC5\DICTS\PINTLGT.IMD
takeown /f %THE_FILE_TO_DELETE%
cacls %THE_FILE_TO_DELETE% /G YourUserName:F
del %THE_FILE_TO_DELETE%

Create Windows PE 5.1 Image

Listed below are the instructsions to create a Windows PE 5.1 x86 disk. To build an amd64 version, replace all ‘x86’ to ‘amd64’ in the commands below.

Prerequisites

Steps

  • Start “Deployment and Imaging Tools Environment” as administrator

  • Copy a basic PE image.

copype x86 C:\WinPE_x86
  • Mount the PE image to local directory
Dism /Mount-Image /ImageFile:"C:\WinPE_x86\media\sources\boot.wim" /index:1 /MountDir:"C:\WinPE_x86\mount"
  • (Optional) Add packages. For example, the following command adds .Net Framework to the PE
Dism /Add-Package /Image:"C:\WinPE_x86\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\x86\WinPE_OCs\WinPE-NetFx.cab"
  • (Optional) Verify packages using the following command (optional)
Dism /Get-Packages /Image:"C:\WinPE_x86\mount"
  • (Optional) Add thridparty programs. For example, the following command adds 7Zip to the PE
copy "C:\Program Files (x86)\7-Zip\7z*.*" C:\WinPE_x86\mount\Windows\System32
  • (Optional) Change PE boot drive letter. For example the following command change the PE’s boot drive to V:
Dism /image:C\WinPE_x86\mount /Set-TargetPath:V:\
  • Unmount the image and commit changes
Dism /Unmount-Image /MountDir:"C:\WinPE_x86\mount" /commit
  • Deploy the PE image to an ISO
MakeWinPEMedia /ISO C:\WinPE_x86 C:\WinPE_x86\WinPE_x86.iso
  • Deploy the PE image to an USB drive (e.g. U:)
MakeWinPEMedia /UFD C:\WinPE_x86 U:

Monday, December 30, 2013

Keep Both Python 2 and Python 3 on Windows

Here is notes to keep both Python 2 and Python 3 working on Windows.

New in Python 3.3

Start from Python 3.3, there is a py.exe installed to %SystemRoot% directory, which is helpful when multiple versions of Python installed.
  • py -2 and py starts Python 2.x
  • py -3 starts Python 3.x

Use shebang in Python scripts

In favor of py.exe, shebang in Python scripts can be recognized on Windows.
  • #! python 3 for Python 3.x
  • #! python 2 for Python 2.x

Installation order matters

If you install python3 first and then Python 2, the setup program of Python 2 will overwrite the .py file association, such that a Python 3 script with shebang #!python 3 will be executed by Python 2. So the better order is install Python 2 first and then Python 3.

Don’t need to add python to PATH

If both Python 2 and Python 3 executables are on PATH, then there will be confusion. Instead of add Python to PATH and call python your-script.py, the following command also work your-script.py.