Link to home
Start Free TrialLog in
Avatar of FFXNZ
FFXNZFlag for New Zealand

asked on

Registry Value Write VB Script

I have the following VBS file

 
On Error Resume Next
Dim wsh,fso,stdClientKeyPath,oReg,logFile,curDir, cmdLine2, cmdLine3, sResult1, AppRemoveKeyPath
strComputer = "."
Const HKLM = &H80000002
stdClientKeyPath = "SOFTWARE\Standard Client\Applications"
AppRemoveKeyPath = "SOFTWARE\Microsoft\Windows\Currentversion\Uninstall\CitrixOnlinePluginFull" 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set wsh = CreateObject("WScript.Shell")
Set objEnv = wsh.Environment("PROCESS")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 


packageName = "Citrix online plug-in - (Production Release 12.1.0.30) - P1"
aVersion = "12.1.0.30"
pVersion = "P1"


objEnv("SEE_MASK_NOZONECHECKS") = 1
curDir = Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\")-1)
strLogPath = wsh.ExpandEnvironmentStrings("%ProgramFiles%")&"\Hewlett-Packard\HPCA\Agent\Log\CITRIX_ONLINE_PLUGIN_12_1_INSTALL.log"

Set logFile = fso.CreateTextFile(strLogPath,True,True)
logFile.WriteLine Date &" "& Time & " Source directory: "& curDir


'***

cmdLine = Chr(34)& curDir & "\Citrix_Online_Plugin_12_1\TrolleyExpress.exe" &Chr(34)& " /silent /noreboot ADDLOCAL="&Chr(34)&"ICA_Client,PN_Agent,SSON,Flash,USB,DesktopViewer"&Chr(34)& " SERVER_LOCATION="&Chr(34)&"http://ctxweb/Citrix/PNAgent/config.xml"&Chr(34)& " ENABLE_SSON="&Chr(34)&"Yes"&Chr(34)
'cmdLine2 = "cmd /c Copy "&Chr(34)&"%TEMP%\CtxInstall*.*"&Chr(34)& " "&Chr(34)&"%ProgramFiles%\Hewlett-Packard\HPCA\Agent\Log"&Chr(34)& " /y"
'cmdLine3 = "cmd /c Copy "&Chr(34)&"%TEMP%\TrolleyExpress*.*"&Chr(34)& " "&Chr(34)&"%ProgramFiles%\Hewlett-Packard\HPCA\Agent\Log"&Chr(34)& " /y"


logFile.WriteLine Date &" "& Time & " Running command: "& cmdLine
	sResult=wsh.run (cmdLine,0,True)
If sResult = 0 Or sResult = 3010 Then
	CreateStdClientRegKey packageName,aVersion,pVersion
	logFile.WriteLine Date &" "& Time & " Standard Reg Key created for " & packageName
End If
logFile.WriteLine Date &" "& Time & " Running command: "& cmdLine2
	sResult1=wsh.run (cmdLine2,0,True)
logFile.WriteLine Date &" "& Time & " Running command: "& cmdLine3
	sResult1=wsh.run (cmdLine3,0,True)
logFile.WriteLine Date &" "& Time & " Return code: "& sResult

logFile.WriteLine Date &" "& Time & " Logging stopped"
logFile.Close
objEnv("SEE_MASK_NOZONECHECKS") = 0	
WScript.Quit(sResult)

'******************* S U B S *******************************

'***
Function CreateStdClientRegKey(appName,appVer,packageVer)
appKeyPath = stdClientKeyPath &"\"& appName
oReg.CreateKey HKLM,appKeyPath
today = CStr(Date)
oReg.SetStringValue HKLM,appKeyPath,"Install Date",today
oReg.SetStringValue HKLM,appKeyPath,"Application Version",appVer
oReg.SetStringValue HKLM,appKeyPath,"Package Version",packageVer
oReg.SetStringValue HKLM,appKeyPath,"Source",curDir
oReg.SetStringValue HKLM,AppRemoveKeyPath,"DisplayName",packageName
End Function
'***

Open in new window


All of it works except for the line
oReg.SetStringValue HKLM,AppRemoveKeyPath,"DisplayName",packageName

Open in new window


Not sure why this reg edit doesn't work...
Avatar of RobSampson
RobSampson
Flag of Australia image

Hi, my assumption would be that the appremovekeypath does not exist:
HKLM\SOFTWARE\Microsoft\Windows\Currentversion\Uninstall\CitrixOnlinePluginFull

Make sure that exists, and then the value should be written.

Regards,

Rob.
Avatar of FFXNZ

ASKER

That key most definitely exists, the value also already exists and I am just wanting to change it with this script.
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
After running the script, have you opened regedit and checked the value was changed?
If the value was changed, but after that the program isn't working properly, you might want to check that you are writing in the right format (you have several options like for example "SetStringValue", "SetExpandedStringValue" and "SetMultiStringValue").
If the value wasn't changed, try to run the script with that line only, and  print all the variables to be sure there's no typo. If that line alone works fine, then probably the one above it has some problem. Again, try to debug each line separately, until all works fine.
If you still get errors, try to get as much info as possible, and post it.Best regards,max
Avatar of FFXNZ

ASKER

oReg.SetStringValue HKLM,AppRemoveKeyPath,"DisplayName",Replace(packageName, "\", "\\")  did the tick, all working now.

Cheers
Great. Thanks for the grade.

Regards,

Rob.