Solved

Registry Value Write VB Script

Posted on 2011-02-27
6
723 Views
Last Modified: 2012-08-13
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...
0
Comment
Question by:FFXNZ
  • 3
  • 2
6 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 34993230
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.
0
 

Author Comment

by:FFXNZ
ID: 34993234
That key most definitely exists, the value also already exists and I am just wanting to change it with this script.
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 34993298
OK, above this line:
oReg.SetStringValue HKLM,AppRemoveKeyPath,"DisplayName",packageName

if you put
On Error GoTo 0

then it should throw an error if it's not working correctly.

What it might be though, is that the packagename contains slashes, which may not write correctly.  Try changing that line to this:
oReg.SetStringValue HKLM,AppRemoveKeyPath,"DisplayName",Replace(packageName, "\", "\\")

Regards,

Rob.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:t-max
ID: 34993403
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
0
 

Author Closing Comment

by:FFXNZ
ID: 34993524
oReg.SetStringValue HKLM,AppRemoveKeyPath,"DisplayName",Replace(packageName, "\", "\\")  did the tick, all working now.

Cheers
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34993529
Great. Thanks for the grade.

Regards,

Rob.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question