Solved

Registry Value Write VB Script

Posted on 2011-02-27
6
726 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

710 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