Video Screencast Help
Protect Your POS Environment Against Retail Data Breaches. Learn More.

Wisescript Editor 8 64 bit operations on Win 7

Created: 09 Nov 2010 • Updated: 10 Nov 2010 | 7 comments
This issue has been solved. See solution.

When will Wisescript Editor 8 be able to handle 64 bit operations? Like Ket Regisrty Key Value on a Windows 7 64bit OS. Is there another solution that can be plugged in?

Comments 7 CommentsJump to latest comment

EdT's picture

Wisescript development is now minimal and so I would realistically assess that there is no chance of a 64 bit version being released at any foreseeable time in the future.

You could use wisescript to call external code which can access the 64 bit registry, but realistically, you should be using the MSI editor which supports 64 bit operations.

However, some time ago a forum member published a solution which uses a call to VBScript to handle registry operations for 32 and 64 bit parts of the registry from Wisescript, and I am reproducing the code below. I have not tested the code, so you will have to make sure it works for your requirements:

 

'Edit Registry Key' script action (64-bit)
 
Here is a 64-bit version of the 'Edit Registry Key' script action.  
 
Main script:
item: Remark
Text=File: UDA Edit Registry Key Value.wse
end
item: Remark
Text=Replacement for the Get Registry Key Value script action
end
item: Remark
Text=Written to work around the limitation of Wise's inability to access the 64-bit portion of the registry.
end
item: Remark
end
item: Remark
Text=Determine if OS is 64 bit
end
item: Get System Information
Variable=X64
Flags=00011000
end
item: Remark
end
item: Set Variable
Variable=REGROOT
Value=%REGROOT%
end
item: Set Variable
Variable=_REGROOT
Value=%_REGROOT%
end
item: Set Variable
Variable=REGKEY
Value=%REGKEY%
end
item: Set Variable
Variable=REGVALNAME
Value=%REGVALNAME%
end
item: Set Variable
Variable=VALUE
Value=%VALUE%
end
item: Set Variable
Variable=REGVALTYPE
Value=%REGVALTYPE%
end
item: Set Variable
Variable=_REGVALTYPE
Value=%_REGVALTYPE%
end
item: Set Variable
Variable=OPERATION
Value=%OPERATION%
end
item: Remark
end
item: Execute VBScript
Pathname=C:\Wise Scripts\User Defined Actions\UDA Edit Registry Key.vbs
end
Exit script and dialog:
item: Custom Dialog Set
Name=Edit Registry Key
item: Dialog
Title=Edit Registry Key Value
Width=219
Height=379
Font Name=Helv
Font Size=8
item: Editbox
Control Name=regkey
Rectangle=70 64 191 78
Variable=REGKEY
Help Context=16711680
Enabled Color=00000000000000001111111111111111
Create Flags=01010000100000010000000010000000
Text=%REGKEY%
end
item: Editbox
Control Name=regvalname
Rectangle=70 81 191 95
Variable=REGVALNAME
Help Context=16711680
Enabled Color=00000000000000001111111111111111
Create Flags=01010000100000010000000010000000
Text=%REGVALNAME%
end
item: Radio Button
Control Name=regroot
Rectangle=19 112 109 175
Variable=REGROOT
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000010000000000001001
Text=HKEY_CLASSES_ROOT
Text=HKEY_CURRENT_USER
Text=HKEY_LOCAL_MACHINE
Text=HKEY_USERS
Text=HKEY_CURRENT_CONFIG
Text=
end
item: Radio Button
Control Name=regsearchtype
Rectangle=125 114 197 138
Variable=REGSEARCHTYPE
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000010000000000001001
Text=Edit the 64-bit registry
Text=Edit the 32-bit registry
Text=
end
item: Editbox
Control Name=regkey
Rectangle=44 209 201 236
Variable=VALUE
Help Context=16711680
Enabled Color=00000000000000001111111111111111
Create Flags=01010000101000010000000010000100
Text=%VALUE%
end
item: Radio Button
Rectangle=18 253 118 318
Variable=OPERATION
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000010000000000001001
Text=Create/update key and value
Text=Create empty key
Text=Remove key and all subkeys
Text=Remove key value only
Text=Preserve existing key and value
Text=
end
item: Radio Button
Control Name=regvaltype
Rectangle=132 255 193 318
Variable=REGVALTYPE
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000010000000000001001
Text=Binary
Text=String
Text=Expanded String
Text=Multi String
Text=DWORD
Text=QWORD
Text=
end
item: Push Button
Rectangle=135 341 170 356
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000010000000000000001
Text=OK
end
item: Push Button
Rectangle=174 341 209 356
Action=3
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000010000000000000000
Text=Cancel
end
item: Static
Rectangle=5 8 209 44
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000000000
Text=Unlike the built-in 'Edit Registry' script action, this user defined action can access both the 32-bit and 64-bit portions of the Windows registry. However, this version can only edit a single key, whereas the built-in action can edit multiple keys in the same dialog.
end
item: Static
Rectangle=19 81 60 95
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000000000
Text=Value Name:
end
item: Static
Rectangle=19 65 60 79
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000000000
Text=Registry Key:
end
item: Static
Control Name=Root
Rectangle=13 106 114 179
Action=3
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000001000
end
item: Static
Rectangle=19 102 36 113
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000000000
Text=Root
end
item: Static
Control Name=Root
Rectangle=125 249 201 321
Action=3
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000001000
end
item: Static
Rectangle=132 245 165 255
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000000000
Text=Type
end
item: Static
Rectangle=119 106 202 179
Action=3
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000001000
end
item: Static
Rectangle=125 103 187 113
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000000000
Text=Behavior on 64-bit OS
end
item: Static
Rectangle=5 53 209 186
Action=1
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000000111
Text=Key to edit
end
item: Static
Rectangle=5 198 209 330
Action=1
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000000111
Text=Data Settings
end
item: Static
Rectangle=13 249 119 321
Action=3
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000001000
end
item: Static
Rectangle=19 244 49 254
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000000000
Text=Operation
end
item: Static
Rectangle=19 210 41 224
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000000000
Text=Value:
end
item: If/While Statement
Variable=DLG_EVENT_TYPE
Value=VERIFY
end
item: If/While Statement
Variable=REGROOT
Value=A
end
item: Set Variable
Variable=_REGROOT
Value=HKEY_CLASSES_ROOT
end
item: ElseIf Statement
Variable=REGROOT
Value=B
end
item: Set Variable
Variable=_REGROOT
Value=HKEY_CURRENT_USER
end
item: ElseIf Statement
Variable=REGROOT
Value=C
end
item: Set Variable
Variable=_REGROOT
Value=HKEY_LOCAL_MACHINE
end
item: ElseIf Statement
Variable=REGROOT
Value=D
end
item: Set Variable
Variable=_REGROOT
Value=HKEY_USERS
end
item: ElseIf Statement
Variable=REGROOT
Value=E
end
item: Set Variable
Variable=_REGROOT
Value=HKEY_CURRENT_CONFIG
end
item: End Block
end
item: If/While Statement
Variable=REGVALTYPE
Value=A
end
item: Set Variable
Variable=_REGVALTYPE
Value=REG_BINARY
end
item: ElseIf Statement
Variable=REGVALTYPE
Value=B
end
item: Set Variable
Variable=_REGVALTYPE
Value=REG_SZ
end
item: ElseIf Statement
Variable=REGVALTYPE
Value=C
end
item: Set Variable
Variable=_REGVALTYPE
Value=REG_EXPAND_SZ
end
item: ElseIf Statement
Variable=REGVALTYPE
Value=D
end
item: Set Variable
Variable=_REGVALTYPE
Value=REG_MULTI_SZ
end
item: ElseIf Statement
Variable=REGVALTYPE
Value=E
end
item: Set Variable
Variable=_REGVALTYPE
Value=REG_DWORD
end
item: ElseIf Statement
Variable=REGVALTYPE
Value=F
end
item: Set Variable
Variable=_REGVALTYPE
Value=REG_QWORD
end
item: End Block
end
item: If/While Statement
Variable=REGSEARCHTYPE
Value=A
end
item: Set Variable
Variable=BIT
Value=64-bit
end
item: ElseIf Statement
Variable=REGSEARCHTYPE
Value=B
end
item: Set Variable
Variable=BIT
Value=32-bit
end
item: End Block
end
item: End Block
end
end
end
Associated VBScript:
Dim strComputer, strOS64, strRegRoot, hexRegRoot, strRegKeyPath, strRegValName, strRegSearchType
Dim strValue, strType, strOperation, strReturnVal, blnSubKeyExists, statusCode, strSubKey
strComputer = "."
strOS64 = GetVariable("X64")
strRegRoot = GetVariable("_REGROOT")
strRegKeyPath = GetVariable("REGKEY")
strRegValName = GetVariable("REGVALNAME")
strRegSearchType = GetVariable("REGSEARCHTYPE")
'strOS64 = "0"
'strRegRoot = "HKEY_LOCAL_MACHINE"
'strRegKeyPath = "Software\Abilene\Games"
'strRegValName = "GameName"
'strRegSearchType = "A"
Select Case strRegRoot
Case "HKEY_CLASSES_ROOT" hexRegRoot = &H80000000
Case "HKEY_CURRENT_USER" hexRegRoot = &H80000001
Case "HKEY_LOCAL_MACHINE" hexRegRoot = &H80000002
Case "HKEY_USERS" hexRegRoot = &H80000003
Case "HKEY_CURRENT_CONFIG" hexRegRoot = &H80000005
Case Else hexRegRoot = "not set"
End Select
strValue = GetVariable("VALUE")
strType = GetVariable("_REGVALTYPE")
strOperation = GetVariable("OPERATION")
'strValue = "Serendipity"
'strType = "REG_SZ"
'strOperation = "A"
Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
'If we are on a 64-bit OS...
If strOS64 = "1" Then
'If instructed to search the 32-bit registry...
If strRegSearchType = "A" Then
' MsgBox "Editing the 64-bit registry key " & strRegKeyPath & "\" & strRegValName & "..."
objCtx.Add "__ProviderArchitecture", 64 
'If instructed to search the 64-bit registry...
Elseif strRegSearchType = "B" Then
' MsgBox "Editing the 32-bit registry key " & strRegKeyPath & "\" & strRegValName & "..."
objCtx.Add "__ProviderArchitecture", 32 
End If
Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx)
Set objReg = objServices.Get("StdRegProv") 
'Else if we are on a 32-bit OS...
Else
' MsgBox "Editing the registry key " & strRegKeyPath & "\" & strRegValName & "..."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
End If
Select Case strOperation
Case "A" ' Create/update key And value
' First create the key if it does not already exist
If Not keyExists(hexRegRoot, strRegKeyPath) Then
objReg.CreateKey hexRegRoot, strRegKeyPath
' MsgBox "New registry key " & strRegKeyPath & " created."
End If
' Then create or update the value
Select Case strType
Case "REG_BINARY"
statusCode = objReg.SetBinaryValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
Case "REG_SZ"
statusCode = objReg.SetStringValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
Case "REG_EXPAND_SZ"
statusCode = objReg.SetExpandedStringValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
Case "REG_MULTI_SZ"
statusCode = objReg.SetMultiStringValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
Case "REG_DWORD"
statusCode = objReg.SetDWORDValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
Case "REG_QWORD"
statusCode = objReg.SetQWORDValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
' Case Else
' statusCode = "-9999992"
End Select
' If statusCode <> 0 Then
' MsgBox "Unable to set value of " & strRegKeyPath & "\" & strRegValName & " to " & strValue & "." & vbCrlf & "statusCode = " & statusCode
' Else
' MsgBox "New registry value " & strRegKeyPath & "\" & strRegValName & " created."
' End If
' MsgBox "Registry key " & strRegKeyPath & "\" & strRegValName & " created/updated."
Case "B" ' Create empty key
If keyExists(hexRegRoot, strRegKeyPath) Then
' Key already exists so leave it alone
' MsgBox "Registry key " & strRegKeyPath & " already exists"
Else
' Key does not exist so create it
objReg.CreateKey hexRegRoot, strRegKeyPath
' MsgBox "New empty registry key " & strRegKeyPath & " created."
End If
Case "C" ' Remove key and all subkeys
statusCode = objReg.DeleteKey(hexRegRoot, strRegKeyPath)
' If statusCode = 0 Then ' Key was successfully deleted
' MsgBox "Registry key " & strRegKeyPath & " was successfully deleted."
' Else
' MsgBox "Registry key " & strRegKeyPath & " does not exist."
' End If
Case "D" ' Remove key value only
statusCode = objReg.DeleteValue(hexRegRoot, strRegKeyPath, strRegValName)
' If statusCode = 0 Then ' Value was successfully deleted
' MsgBox "Registry key value " & strRegKeyPath & "\" & strRegValName & " was successfully deleted."
' Else
' MsgBox "Registry key value " & strRegKeyPath & "\" & strRegValName & " does not exist."
' End If
Case "E" ' Preserve existing key and value (ie. Add key and value if they do not already exist,
' but leave existing value in place if it already exists.)
' MsgBox "strType = " & strType & vbCrLf & "strValue = " & strValue
Select Case strType
Case "REG_BINARY"
statusCode = objReg.GetBinaryValue(hexRegRoot, strRegKeyPath, strRegValName, strVal)
Case "REG_SZ"
statusCode = objReg.GetStringValue(hexRegRoot, strRegKeyPath, strRegValName, strVal)
Case "REG_EXPAND_SZ"
statusCode = objReg.GetExpandedStringValue(hexRegRoot, strRegKeyPath, strRegValName, strVal)
Case "REG_MULTI_SZ"
statusCode = objReg.GetMultiStringValue(hexRegRoot, strRegKeyPath, strRegValName, strVal)
Case "REG_DWORD"
statusCode = objReg.GetDWORDValue(hexRegRoot, strRegKeyPath, strRegValName, strVal)
Case "REG_QWORD"
statusCode = objReg.GetQWORDValue(hexRegRoot, strRegKeyPath, strRegValName, strVal)
Case Else
statusCode = "-1"
End Select
If statusCode <> 0 Then ' Registry value does not exist so create it
' MsgBox "Registry value " & strRegValName & " does not exist."
' Check to see if the key (not the value) exists, and if not, it will also need to be created
If Not keyExists(hexRegRoot, strRegKeyPath) Then
objReg.CreateKey hexRegRoot, strRegKeyPath
' MsgBox "New registry key " & strRegKeyPath & " created."
End If
' Then set the value
Select Case strType
Case "REG_BINARY"
statuscode = objReg.SetBinaryValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
Case "REG_SZ"
statusCode = objReg.SetStringValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
Case "REG_EXPAND_SZ"
statusCode = objReg.SetExpandedStringValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
Case "REG_MULTI_SZ"
statusCode = objReg.SetMultiStringValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
Case "REG_DWORD"
statusCode = objReg.SetDWORDValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
Case "REG_QWORD"
statusCode = objReg.SetQWORDValue(hexRegRoot, strRegKeyPath, strRegValName, strValue)
Case Else
statusCode = "-1"
End Select
' If statuscode <> 0 Then
' MsgBox "Unable to set value of " & strRegKeyPath & "\" & strRegValName & " to " & strValue & "."
' Else
' MsgBox "New registry value " & strRegKeyPath & "\" & strRegValName & " created."
' End If
' Else
' MsgBox "Registry key and value " & strRegKeyPath & "\" & strRegValName & " already exists."
End If
End Select 

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

amilani's picture

Here's the link to the solution a member published and then I made some fixes to:

https://www-secure.symantec.com/connect/downloads/...

This includes reading and enumerating registry entries.

I currently use this for an installer that works with all Windows OSs.

 

Nomi1985's picture

You can access the 64-bit registry and the 64-bit windows directories by disabling file/registry redirection, doing whatever task you need to do, and then enabling file/registry redirection again.  Here is the code to do so:

item: Get System Information
  Variable=IS_64_BIT_OS
  Flags=00011000
end
item: Remark
  Text=If the OS is 64-bit then...
end
item: If/While Statement
  Variable=IS_64_BIT_OS
  Value=1
end
item: Set Variable
  Variable=IS_64_BIT_OS
  Value=TRUE
end
item: End Block
end
item: Remark
  Text=If the OS is 32-bit then...
end
item: If/While Statement
  Variable=IS_64_BIT_OS
  Value=0
end
item: Set Variable
  Variable=IS_64_BIT_OS
  Value=FALSE
end
item: End Block
end
item: Remark
end
item: Remark
  Text=If you need to disable WOW64 file redirection so that you can access 64-Bit OS components and directories on 64-bit systems, use the following code
end
item: If/While Statement
  Variable=IS_64_BIT_OS
  Value=FALSE
end
item: Else Statement
end
item: Remark
  Text=Disable WOW64 File Redirection
end
item: Call DLL Function
  Pathname=%SYS32%\kernel32.dll
  Function Name=Wow64DisableWow64FsRedirection
  Argument List=70OLD64FSVALUE
  Return Variable=2ERRCODE64FS
  Flags=01100000
end
item: Remark
  Text=Execute/Access 64-bit OS components and directories here.
end
item: Remark
end
item: Remark
  Text=Enable WOW64 File Redirection
end
item: Call DLL Function
  Pathname=%WIN%\SysWow64\kernel32.dll
  Function Name=Wow64RevertWow64FsRedirection
  Argument List=21%OLD64FSVALUE%
  Return Variable=2ERRCODE64FS
  Flags=00100000
end
item: End Block
end

Nomi1985's picture

I like my method above better b/c VBScript does not let you write large binary/hex values to the registry b/c of limitations.  In such cases, you would have to use my method above and use Wise's built in registry editing Custom Actions.  If you want to use the VBScript Custom Actions for editing the 64-bit registry someone posted on this blog a long time ago, then you would be better served to use my updated Custom Actions b/c there were at least two bugs in them that I fixed.  I don't remember where the bugs were or what they were, but take it from me that they were there and they are fixed in the files I am attachign to this post.  I have been using these Custom Actions for a while now with no problems.

AttachmentSize
64-Bit Registry Custom Actions.zip 11.62 KB
SOLUTION
IHS-Packager's picture

Nomi1985,

I have placed the files on my 64 bit Win7 @ C:\Program Files (x86)\Altiris\Wise Package Studio\WiseScript Editor\Actions. We are testing it out and so far, so good. Thank You!

It is greatly appreciated!

IHS-Packager

VBScab's picture

         >VBScript does not let you write large binary/hex values to the registry b/c of limitations

VBScript has no such limitation. Rather, the nasty Shell RegRead/RegWrite access to the registry does.

Why anyone persists with that thing is a mystery to me. Using the WMI StdRegProv provides everything you could need. http://msdn.microsoft.com/en-us/library/aa393067%28VS.85%29.aspx

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.

Nomi1985's picture

Yes, you're right.  The limitation was with with Wise actually.  I was not able to append the really large binary/hex value to a variable and write it using the VBScript custom actions.  It worked when I used Wise's registry custom actions and just imported the reg file data I wanted to write to the registry.  The VBScripts do use StdRegProv for writing to the registry.