November 13, 2012

Edit Registry on a mounted WIM

This guide assumes that ImageX is avaliable on your computer. (Avaliable via Windows Automated Installation Kit (WAIK).

Mount the WIM file

Mount the WIM file to a local folder using ImageX. C:\ImageX>imagex /mountrw install.wim 1 c:\mount

Load the registry hive

Load the registry hive you need. In this case let’s mount HKLM\Software.

C:\mount reg load HKLM\test c:\mount\windows\system32\config\software

Open Regedit to make changes or use Reg Add from the command line.

Unload the reg hive

C:\Windows\system32 reg unload HKLM\test

Unmount the image

C:\ImageX>imagex /unmount /commit c:\mount

Capture image using ImageX

When doing the capture you should have booted into WinPE. You can place the wim file on a remote file share aswell as locally. To use a remote file share map it as a network drive when booted into WinPE.

imagex /capture c: t:\my-windows-partition.wim “My Windows partition”

The following commandline parameters can be added to the above

/compress [maximum | fast | none] : Specifies the type of compression used for the initial capture operation

/check : Checks the integrity of the .wim file. If not provided, existing checks are removed.

For full documentation see: http://technet.microsoft.com/en-us/library/cc749447(WS.10).aspx

Update WinPE Boot image driver

When adding a driver to WinPE make sure that you choose Windows Vista drivers since WinPE is based on Windows Vista.

Intels WinPE/Windows Vista drivers are found in the PRO1000\Win32\NDIS61 folder after having extracted the drivers from ie. PROWin32.exe downloaded from Intel

For bonus info the extract command on the PROWin32.exe is /f “destination”.

Using a PAC file to restrict access to Websites

If you want to control which websites can be accessed from one or more computers a PAC file solution can be used.

The PAC file is a fairly simple file containing information on which sites can or cant be accessed – depending on what your needs are. This means you can set up a solution where all websites can be accessed except from the ones in your PAC file or you can setup a solution where all websites are blocked except from the ones in the PAC file.

In Internet Explorer you then have to enable the “Use automatic configuration script” under Tools > Internet Options > Connections > LAN Setting and then point to the location of your PAC file. The PAC file can be placed both locally or on a webserver.

Example of a PAC file where only the sites *.google.com, *.facebook.com and *.msn.com can be accessed (Proxy.pac):

function FindProxyForURL(url, host)
 {
// variable strings to return
 var access = "PROXY servername.domain.com:8080";
 var noaccess = "PROXY 127.0.0.1:80";
 if (shExpMatch(host, "*.google.com")) { return access; }
 if (shExpMatch(host, "*.facebook.com")) { return access; }
 if (shExpMatch(host, "*.msn.com")) { return access; }
 // Proxy anything else
 return noaccess;
 }

Example of a PAC file where the above sites are blocked and all other sites can be accessed.

function FindProxyForURL(url, host)
 {
// variable strings to return
 var access = "PROXY servername.domain.com:8080";
 var noaccess = "PROXY 127.0.0.1:80";
 if (shExpMatch(host, "*.google.com")) { return noaccess; }
 if (shExpMatch(host, "*.facebook.com")) { return noaccess; }
 if (shExpMatch(host, "*.msn.com")) { return noaccess; }
 // Proxy anything else
 return access;
 }

 

Windows Time Zone

I made a script to update the Windows Time Zone. In my example i want to use the Romance Standard time which is easily done by specifying this as an argument to the function SetTimeZone

SetTimeZone("Romance Standard Time")

Sub SetTimeZone(timezone)

On Error Resume Next

Set objSh = CreateObject("WScript.Shell")

Dim process, processid, strUpdateCommand
 Set process = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2:Win32_process")

'Add time change privilege to the process object
 process.Security_.Privileges.AddAsString "SeSystemTimePrivilege",True
 strUpdateCommand = "control.exe timedate.cpl,,/Z" & timezone

'Launch control.exe to refresh time zone information
process.create strUpdateCommand,Null,Null,processid

End Sub

Bootable USB

This guide will tell you how to make a bootable USB. To make the bootable USB you need to use DISKPART which comes with Windows. Its important tho that you use either Windows Vista or Windows 7 otherwise DISKPART cant detect your USB key as a drive.

Start your command prompt and type diskpart – this will open a new diskpart window. The rest is shown in the screendump below.

Change Shutdown Setting

When doing automated reboots using shutdown.exe in my scripts i sometimes need to change back the default shutdown option so the user will have “Shutdown” as the default selection in the shutdown box.

The shutdown setting determining the default shutdown option – (log off, shutdown, restart, standby, hibernate, disconnect) can be found in the registry under current user settings.

Key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer
Value: Shutdown Setting
Type: REG_DWORD
Radix: Hex
Data: 00000002

The possible values for Shutdown Setting are:

00000001 = Log Off
00000002 = Shut Down
00000004 = Restart
00000010 = Stand By
00000020 = Stand By (with wakeup events disabled)
00000040 = Hibernate
00000080 = Disconnect (only available in Terminal Services sessions)

Slipstream updates into your Office 2007 installation

I recently had to update a standard Office 2007 installation with SP2. This is easily done with a few commandlines assuming that you have both downloaded the SP2 update and have the Office 2007 installation files already avaliable.

Locate the Updates folder among your Office 2007 installation files. This is the folder where we want the SP2 files to end up. In my example the path to the updates folder is :

E:\Office2007\Updates

I placed the SP2 update in a temporary folder:

E:\Temp\Office2007-SP2-Update\office2007sp2-kb953195-fullfile-da-dk.exe

To extract the SP2 update and thereby slipsteam the SP2 update into the Office 2007 installation simply type the following:

E:\Temp\Office2007-SP2-Update\office2007sp2-kb953195-fullfile-da-dk.exe /extract:”E:\Office2007\Updates”

Accept the licence agreement and follow the steps until you get a confirmation that the installation is complete.

Now you are ready to install Office 2007 SP2.

If you want to slipsteam other Windows updates into your Office 2007 installation files simply repeat the steps above only by replacing the update you want to slipsteam.