use Variable on VBS

Posted by Amirreza on Stack Overflow See other posts from Stack Overflow or by Amirreza
Published on 2012-12-17T22:55:57Z Indexed on 2012/12/17 23:03 UTC
Read the original article Hit count: 219

Filed under:
|
|

I Convert a reg file to VBS commands.

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
@=""
"VPService"="C:\\Windows\\System32\\VPService.exe"

but i can't use %systemroot% variable instead C:\Windows\ on this.

Option Explicit
Dim objShell
Set objShell = CreateObject("WScript.Shell")

Dim strComputer, ArrOfValue, oReg
const HKEY_USERS = &H80000003
const HKEY_LOCAL_MACHINE = &H80000002
const HKEY_CURRENT_USER = &H80000001
const HKEY_CLASSES_ROOT = &H80000000
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\", ""
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\", "", "REG_SZ" 'Default value
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\VPService", "C:\\Windows\\System32\\VPService.exe", "REG_SZ"
Set objShell = Nothing
WScript.Quit

how can use %systemroot% variable instead C:\Windows\ on this code?

© Stack Overflow or respective owner

Related posts about variables

Related posts about vbscript