Solved

Registry Value Write VB Script

Posted on 2011-02-27
6
696 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now