November 2012

Debugging entry points for package.ini

I recently had to make a thinapp version of an application which among other features had some database integration. To allow connection to the database the installation created two services. After having made a build of my capture and thereby the thinapp i was uncertain wether i actually succeeded at virtualizing the services.

As the virtualized services are only visible from inside the thinapp “bubble” i had to create an entry point to services.msc in my package.ini. This way i could launch services.msc before my thinapp to verify that the services actually were created.

The entry point i added for services.msc looks like this:

[Services (ThinApp).exe]
Disabled=0
Shortcut=<PACKAGE SOURCE FILE>
Source=%SystemSystem%\MMC.EXE
CommandLine=%SystemSystem%\MMC.EXE %SystemSystem%\SERVICES.MSC
Icon=C:\Windows\system32\filemgmt.dll,0


See the Vmware blog for more entry points:

http://blogs.vmware.com/thinapp/2008/10/creating-window.html

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" &amp; 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)