Solved

Registry Value Write VB Script

Posted on 2011-02-27
6
735 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

628 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