I have a script that writes a .reg file and a batch file to import the .reg file. After the batch file has been writen I call it to do the import (it's a REG_BINARY key so I though regedit would be the easiest way..)
However when the script runs it loops and the batch file runs several times. code below, I'm a bit of a VBscript amateur so bear with me
However when the script runs it loops and the batch file runs several times. code below, I'm a bit of a VBscript amateur so bear with me
Code:
Const HKEY_CURRENT_USER = &H80000001
set fso = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
ProfileName = subkey
Next
RegFileName = "c:\Documents and Settings\All Users\setArchiveLocation.reg"
set regFileObj = fso.createtextfile(RegFileName,true)
regFileObj.WriteLine "Windows Registry Editor Version 5.00"
regFileObj.WriteLine VbCr
regFileObj.WriteLine "[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"& ProfileName &"]"
regFileObj.WriteLine VbCr
regFileObj.WriteLine "[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"& ProfileName &"\0a0d020000000000c000000000000046]"
regFileObj.WriteLine VbCr
regFileObj.WriteLine """001f0324""=hex:54,00,3a,00,5c,00,61,00,72,00,63,00,68,00,69,00,76,00,65,00,31,\"
regFileObj.WriteLine " 00,2e,00,70,00,73,00,74,00,00,00"
regFileobj.close
BatFileName = "c:\Documents and Settings\All Users\RegImport.bat"
set regImportObj = fso.createtextfile(BatFileName,true)
regImportObj.WriteLine "regedit /s ""C:\Documents and Settings\All Users\setArchiveLocation.reg"""
regImportObj.WriteLine "exit"
' regImportObj.WriteLine "pause"
regImportObj.close
Set shell = CreateObject ("Wscript.Shell")
shell.run ("%comspec% /K ""C:\Documents and Settings\All Users\RegImport.bat"""), 1, True
set shell=nothing
wscript.sleep 1000
fso.DeleteFile "c:\Documents and Settings\All Users\RegImport.bat"
fso.DeleteFile "c:\Documents and Settings\All Users\setArchiveLocation.reg"
wscript.quit