Hi,

I have created a VBS which does the following,

Checks for a HKCU key, i its there, delete it, then checks if a patch is installed, if not there install the patch. However after these 2 functions i need to delete a shortcut on the desktop and add another registry key, I tried running a batch file which is called by the same script but it doesnt run. The shortcuts are created by the MSP install so im assuming, the action to delete the shortcut is done before even the shortcuts are there....is there anyway I can make this work? the one in bold is not working

On Error Resume Next
Const HKEY_CURRENT_USER = &H80000001

Dim sPath, LRC, wshShell, wshNetwork, wmiLocator, wmiNameSpace, objRegistry, strCmd, myRun, strCurrentDir
Set wshShell = WScript.CreateObject ("WScript.Shell")
Set wshNetwork = CreateObject("WScript.Network")
Set wmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set wmiNameSpace = wmiLocator.ConnectServer(wshNetwork.ComputerName, "root\default")
Set objRegistry = wmiNameSpace.Get("StdRegProv")

sPath = "SOFTWARE\IXOS\IXOS_ARCHIVE\CWin\DesktopLink\NA_R3_620"
lRC = DeleteRegEntry(HKEY_CURRENT_USER, sPath)
WScript.Sleep 100

Function DeleteRegEntry(sHive, sEnumPath)
Dim sNames, sKeyName
lRC = objRegistry.DeleteKey(sHive, sEnumPath)
If (lRC <> 0) Then
On Error Resume Next
lRC = objRegistry.EnumKey(HKEY_CURRENT_USER, sEnumPath, sNames)

For Each sKeyName In sNames
If Err.Number <> 0 Then Exit For
lRC = DeleteRegEntry(sHive, sEnumPath & "\" & sKeyName)
Next

On Error Goto 0
lRC = objRegistry.DeleteKey(sHive, sEnumPath)
End If
End Function

On Error Resume Next

strCurrentDir = Left(Wscript.ScriptFullName, (InstrRev(Wscript.ScriptFullName, "\") -1))
If RegistryValueExists("HKLM","Software\Microsoft\Windows\CurrentVersion\Uninstall\{96538711-469D-4B19-B2F3-F1E49F4A9E0E}","Comments") Then
strCmd = "msiexec.exe /update " & chr(34) & strCurrentDir & "\Config\VU095-052.msp" & chr(34) &_
"REBOOT=ReallySuppress /l*v c:\wdgt.log /qb-!"
myRun = WshShell.run(strCmd,0,True)
End If
WScript.Quit


Function RegistryValueExists(LNGHKEY, strKeyPath, strValueName)

On Error Resume Next

Const HKLM = &H80000002
Const HKCR = &H80000000
Const HKCU = &H80000001
Const HKUSERS = &H80000003
RegistryValueExists = False

Dim hkRoot, strValue, stdOut, oReg

If LNGHKEY = "HKLM" Then hkRoot = HKLM
If LNGHKEY = "HKCU" Then hkRoot = HKCU
If LNGHKEY = "HKCR" Then hkRoot = HKCR
If LNGHKEY = "HKUSERS" Then hkRoot = HKUSERS

Set StdOut = WScript.StdOut
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
oReg.GetStringValue hkroot,strKeyPath,strValueName,strValue

If strValue <> "Patch VU095-052 is installed" Then
RegistryValueExists = True
End If
End Function

On Error Resume Next
Set sho = Wscript.CreateObject("Wscript.Shell")
strCurrentDir = Left(Wscript.ScriptFullName, (InstrRev(Wscript.ScriptFullName, "\") -1))
strCommand = "cmd.exe /c " & chr(34) & strCurrentDir & "\DeleteShortcuts.bat"
intRet = sho.run(strCommand,0,True)
wscript.quit(intRet)
1 Comment   [ + ] Show Comment

Comments

  • Hello to all, let me know if you are interested in some VB Scripts for packaging different applications and not only, for adding services, renaming files or extension of files and many more. Thank you.
Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
so im assuming, the action to delete the shortcut is done before even the shortcuts are thereSurely a 'PackageExpert' wouldn't need to assume that at all? He would know, right? LOL

Anyway, if your CA is scheduled before the CreateShortcuts action then yes, it will have no effect as far as the s/c deletion is concerned. A log of the install will show you that, if you don't know how to determine the installation sequence. An expert would.

Lastly, please use the CODE tag when posting code or lengthy text of any kind. You add the tag using the button marked '<%' in the 'Reply to Message' or 'Post New Thread' windows
Answered 07/27/2009 by: VBScab
Red Belt

Please log in to comment
0
Timeout...are you installing with user or system rights?

Also, is the icon on the All Users desktop or the install account's desktop?
Answered 07/27/2009 by: elgwhoppo
Senior Purple Belt

Please log in to comment
0
lol do not associate my nickname with the issue aight....its not technically associated...lol....only from the name....im not using MSI here...im using an independent VBS.....

Im logged in as administrator....shortcuts are to all users....this is definitely not rights issue..something wrong with the VBS...as i am just beginner in scripting VBS....
Answered 07/27/2009 by: PackageExpert
Blue Belt

Please log in to comment
0
...all of which is irrelevant. If your CA occurs before the CreateShortcuts, then of course it won't work.

Also, why bother with a script? Use the RemoveFile table http://msdn.microsoft.com/en-us/library/aa371201%28VS.85%29.aspx
Answered 07/28/2009 by: VBScab
Red Belt

Please log in to comment
0
allright will have a look at that... thanks for recommendation....
Answered 07/28/2009 by: PackageExpert
Blue Belt

Please log in to comment
0

Hello Guys, I would like to post some VB Scripts that I, let's say, customized, on my daily work basis, for installing some bundle applications like PTC Creo 2.0, Adobe Framemaker 9 etc...

Answered 01/09/2014 by: ikeen
White Belt

Please log in to comment
Answer this question or Comment on this question for clarity