Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

How to install MSP on selected computers via GPO Startup VBscript

$
0
0

Hi folks,

I'm trying to write a vbscript that will run on startup and do the following:

1) Detect whether or not a particular application is installed

2) Determine if the latest version of said application is installed

3) If not, run the MSP update from a server and apply the patch before login.

I'm on a domain, and the script works when manually run from a command prompt.  I also have the script added to a test GPO under Computer Config>Windows Settings>Startup, but since this is my first real attempt at scripting, I'm not sure how to determine why the *.MSP file isn't running and get this working.

Here's my code so far:

Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE

    strComputer = "."
    strKey = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
    strEntry1a = "DisplayName"
    strEntry1b = "QuietDisplayName"
    strEntry1c = "DisplayVersion"
    strEntry1d = "UninstallString"


'    Set args = Wscript.Arguments	' Get Command Line Argument
'    strVersion = WScript.Arguments.Item(0)

    Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
    objReg.EnumKey HKLM, strKey, arrSubkeys
intVersionNum="1.0"
    For Each strSubkey In arrSubkeys
    intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, strEntry1a, strValue1)
if intRet1 <> "" Then
objReg.GetExpandedStringValue HKLM, strKey & strSubkey, strEntry1a, strValue1
intCompare=StrComp("Adobe Acrobat XI Pro",strValue1,vbTextCompare)
    IF intCompare = 0 THEN
objReg.GetExpandedStringValue HKLM, strKey & strSubkey, strEntry1c, intVersionNum
    END IF
End If
Next

IF intVersionNum="1.0" THEN
        WScript.Quit 2			' Not Found 
END IF

intVersionCompare=StrComp("11.0.06",intVersionNum,vbTextCompare)
IF intVersionCompare = 0  THEN		' Everything OK
WScript.Quit 0
ELSE					' Run Update
Set oShell = WScript.CreateObject("WSCript.shell")
oShell.run "msiexec.exe /update \\RedactedServer\gpo\Acrobat\AcrobatXIPro\AcrobatUpd11006.msp /quiet"
WScript.Quit 1
END IF


Note: RedactedServer isn't a variable; I removed our servername.  Also, I'm reasonably certain there isn't a permissions issue because we use the \\RedactedServer\GPO\ to successfully deliver all of our MSI GPO updates.

When I restart, it looks like the script starts to run(?), but the update isn't installed.  In the Application log, all I see is this:

But, there's no follow-up entry indicating that it was successful or even completed.

Ideally, I'd also like to be able to pass in a command line parameter from the GPO so I can update it without having to edit the script every time a new update comes out, but I'd prefer to run before I fly.

Lastly, yes, the script is looking for Adobe Acrobat XI Pro.  I'm aware I can slipstream the MSP into an AIP and push it that way, but I don't want to redeploy a 2.3 GB installation to each computer that needs an update every 3 months when this will accomplish the goal much quicker and more efficiently.

Does anyone have ideas?  I've beat my head against this all day, and my search-fu doesn't seem to be helping me find the answers I need.

Thanks,

Rick


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>