Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding to registry

Status
Not open for further replies.

Ouch

Programmer
Jul 17, 2001
159
GB
how would i add the following to the registry a using vbscript file

i need to do and undo it on a regular basis

REGEDIT4
; 05/12/2002 16:04:47 - 05/12/2002 16:04:53

; ADD section

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections]
"Dialup to Internet"=hex(03):3c,00,00,00,16,00,00,00,05,00,00,00,00,00,00,00, 00,00,00,00,16,00,00,00,68,74,74,70,3a,2f,2f,77,70,61,64,2e,62,68,61,6d,2e, 61,63,2e,75,6b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 00,00,00,00,00,00,00
"SavedLegacySettings"=hex(03):3c,00,00,00,34,01,00,00,01,00,00,00,00,00,00, 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 00,00,00,00,00,00,00,00,00,00,00

 
I cant get it to work? it reterns expected statement error



Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections\Dialup to Internet", hex(03):3c,00,00,00,16,00,00,00,05,00,00,00,00,00,00,00,\00,00,00,00,16,00,00,00,68,74,74,70,3a,2f,2f,77,70,61,64,2e,62,68,61,6d,2e,\61,63,2e,75,6b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\00,00,00,00,00,00,00 ,"REG_BINARY"


WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections\SavedLegacySettings", hex(03):3c,00,00,00,34,01,00,00,01,00,00,00,00,00,00,\00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\00,00,00,00,00,00,00,00,00,00,00 , "REG_BINARY"
 
It looks like there is a limitation on using regwrite with hex values. Here is a different way to do it. Not as pretty, but it should work.

TQ

'Import Registry Settings

set oFile = CreateObject("scripting.FileSystemObject")
set oShell = CreateObject("wscript.shell")

sRegFile = "C:\WINDOWS\DESKTOP\ENTRY.REG"

if oFile.FileExists(sregfile) then
iReturn = oShell.Run("regedit.exe /s" & sRegFile)
if iReturn <> 0 then
wscript.echo &quot;Import Reg Settings Failed! &quot; & err.number & &quot;:&quot; & err.description
end if
else
wscript.echo &quot;Registry Import Failed.&quot;
end if

set ofile = nothing
set oshell = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top