I want to have my startup script automatically set the taskbar to hidden but the registrywritekey isn't working since the value must be hex. Am I missing something obvious here?
/*
hide:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3]
"Settings"=hex:30,00,00,00,fe,ff,ff,ff,03,00,00,00,03,00,00,00,4e,00,00,00,26,\
00,00,00,00,00,00,00,12,04,00,00,80,07,00,00,38,04,00,00,78,00,00,00,01,00,\
00,00
*/
/*
unhide:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3]
"Settings"=hex:30,00,00,00,fe,ff,ff,ff,02,00,00,00,03,00,00,00,4e,00,00,00,26,\
00,00,00,00,00,00,00,12,04,00,00,80,07,00,00,38,04,00,00,78,00,00,00,01,00,\
00,00
*/
RegistryWriteKey (write hex value)
Moderators: JRL, Dorian (MJT support)
- Grovkillen
- Automation Wizard
- Posts: 1132
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: RegistryWriteKey (write hex value)
Hi,
RegistryWriteKey doesn't support binary values. You can do it with a bit of VBScript like this:
You would need to convert your binary dump to a hex &h value though.
I did find some VBScript functions someone had written which use the comma separated binary values here:
https://rcmtech.wordpress.com/2012/03/0 ... ry-values/
Using this we end up with:
Which does what you want.
RegistryWriteKey doesn't support binary values. You can do it with a bit of VBScript like this:
Code: Select all
VBSTART
Set WshShell = CreateObject("WScript.Shell")
WshShell.RegWrite "HKEY_CURRENT_USER\MJTNET\TEST", &H00239856, "REG_BINARY"
VBEND
I did find some VBScript functions someone had written which use the comma separated binary values here:
https://rcmtech.wordpress.com/2012/03/0 ... ry-values/
Using this we end up with:
Code: Select all
VBSTART
Sub regWriteBinary(sRegKey, sRegValue, sBinaryData)
' Expects sBinaryData to be a comma separated string of hex values
' sRegKey needs to start with full registry root, e.g. HKEY_CURRENT_USER and not VBScript short form HKCU
Dim oShell, oFSO, oFile, oExec
Dim sTempFile
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sTempFile = oShell.ExpandEnvironmentStrings("%temp%\RegWriteBinary.reg")
Set oFile = oFSO.CreateTextFile(sTempFile,True)
oFile.WriteLine("Windows Registry Editor Version 5.00")
oFile.WriteLine("")
oFile.WriteLine("[" & sRegKey & "]")
oFile.WriteLine(Chr(34) & sRegValue & Chr(34) & "=" & "hex:" & sBinaryData)
oFile.Close
Set oExec = oShell.Exec("reg.exe import """ & sTempFile & """")
If InStr(1,oExec.StdErr.ReadAll,"operation completed successfully",vbTextCompare) Then
' Yes the success text IS sent out via StdErr and NOT StdOut
'WScript.Echo "Registry updated sucessfully"
oFSO.DeleteFile sTempFile
Else
WScript.Echo "regWriteBinary: Registry import of " & sTempFile & " failed: " & oExec.StdErr.ReadAll
End If
End Sub
VBEND
Let>value=30,00,00,00,fe,ff,ff,ff,03,00,00,00,03,00,00,00,4e,00,00,00,26,00,00,00,00,00,00,00,12,04,00,00,80,07,00,00,38,04,00,00,78,00,00,00,01,00,00,00
VBRun>regWriteBinary,HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3,Settings,value
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Grovkillen
- Automation Wizard
- Posts: 1132
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: RegistryWriteKey (write hex value)
I didn't see why I needed to use VBScript for this... but thanks to your input I got this:Marcus Tettmar wrote: ↑Thu Feb 06, 2020 8:41 amWhich does what you want.Code: Select all
VBSTART Sub regWriteBinary(sRegKey, sRegValue, sBinaryData) ' Expects sBinaryData to be a comma separated string of hex values ' sRegKey needs to start with full registry root, e.g. HKEY_CURRENT_USER and not VBScript short form HKCU Dim oShell, oFSO, oFile, oExec Dim sTempFile Set oShell = CreateObject("WScript.Shell") Set oFSO = CreateObject("Scripting.FileSystemObject") sTempFile = oShell.ExpandEnvironmentStrings("%temp%\RegWriteBinary.reg") Set oFile = oFSO.CreateTextFile(sTempFile,True) oFile.WriteLine("Windows Registry Editor Version 5.00") oFile.WriteLine("") oFile.WriteLine("[" & sRegKey & "]") oFile.WriteLine(Chr(34) & sRegValue & Chr(34) & "=" & "hex:" & sBinaryData) oFile.Close Set oExec = oShell.Exec("reg.exe import """ & sTempFile & """") If InStr(1,oExec.StdErr.ReadAll,"operation completed successfully",vbTextCompare) Then ' Yes the success text IS sent out via StdErr and NOT StdOut 'WScript.Echo "Registry updated sucessfully" oFSO.DeleteFile sTempFile Else WScript.Echo "regWriteBinary: Registry import of " & sTempFile & " failed: " & oExec.StdErr.ReadAll End If End Sub VBEND Let>value=30,00,00,00,fe,ff,ff,ff,03,00,00,00,03,00,00,00,4e,00,00,00,26,00,00,00,00,00,00,00,12,04,00,00,80,07,00,00,38,04,00,00,78,00,00,00,01,00,00,00 VBRun>regWriteBinary,HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3,Settings,value
Code: Select all
SRT>SET_REGISTRY_FOR_TASKBAR
If>SET_REGISTRY_FOR_TASKBAR_Var_1=hide
Let>SET_REGISTRY_FOR_TASKBAR_STATE=03
Else>
Let>SET_REGISTRY_FOR_TASKBAR_STATE=02
Endif>
Let>HEX_CODE=30,00,00,00,fe,ff,ff,ff,%SET_REGISTRY_FOR_TASKBAR_STATE%,00,00,00,03,00,00,00,4e,00,00,00,26,00,00,00,00,00,00,00,12,04,00,00,80,07,00,00,38,04,00,00,78,00,00,00,01,00,00,00
Let>FILE_CONTENTS=Windows Registry Editor Version 5.00%CRLF%
ConCat>FILE_CONTENTS,[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3]%CRLF%
ConCat>FILE_CONTENTS,"Settings"=hex:
ConCat>FILE_CONTENTS,HEX_CODE
DeleteFile>%SCRIPT_DIR%\temp.reg
WriteLn>%SCRIPT_DIR%\temp.reg,,FILE_CONTENTS
RunProgram>cmd /k reg.exe import "%SCRIPT_DIR%\temp.reg"
Wait>1
DeleteFile>%SCRIPT_DIR%\temp.reg
END>SET_REGISTRY_FOR_TASKBAR

- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: RegistryWriteKey (write hex value)
Because as I said:Grovkillen wrote: ↑Thu Feb 06, 2020 12:40 pmI didn't see why I needed to use VBScript for this... but thanks to your input I got this:
So a different method was needed.RegistryWriteKey doesn't support binary values
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Grovkillen
- Automation Wizard
- Posts: 1132
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: RegistryWriteKey (write hex value)
Yes I realized that but as you see I did it all in MS..Marcus Tettmar wrote: ↑Thu Feb 06, 2020 2:27 pmBecause as I said:Grovkillen wrote: ↑Thu Feb 06, 2020 12:40 pmI didn't see why I needed to use VBScript for this... but thanks to your input I got this:
So a different method was needed.RegistryWriteKey doesn't support binary values

- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: RegistryWriteKey (write hex value)
Fair enough
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?