System registry example
Previous  Top  Next

' This script will add a value to the system registry.
'
' We do this by creating a .reg file and then executing "regedit /s" as
' an external process so it will access the system registry instead of the
' virtual registry.


Function OnFirstParentStart
' We need to create the .reg file in a place which has IsolationMode set to
' Merged, so we can access it easily from both the virtual environment (this
' script) and the system environment (regedit /s). One directory which has
' a Merged IsolationMode by default is the %Personal% directory, so let's
' create the reg file there

RegFileName = ExpandPath("%Personal%\thin.reg")
Set fso = CreateObject("Scripting.FileSystemObject")
Set RegFile = fso.CreateTextFile(RegFileName, true)

' Construct the .reg file

RegFile.WriteLine("Windows Registry Editor Version 5.00")
RegFile.WriteBlankLines(1)
RegFile.WriteLine("[HKEY_CURRENT_USER\Software\Thinstall\demo]")
RegFile.WriteLine(chr(34) & "InventoryName" & chr(34) & "=" & chr(34) & GetBuildOption("InventoryName") & chr(34))
RegFile.Close

' Enter the info into the system registry, wait until it is done

RegEditPid = ExecuteExternalProcess("regedit /s " & chr(34) & RegFileName & chr(34))
WaitForProcess RegEditPid, 0

' Clean up

fso.DeleteFile(RegFileName)
End Function