GPO Logon/Script

Currently we run software on about 3000 machines on our network.  What I am wanting to do is have a verify install script that runs on login.  If the verify comes back saying it that isn't installed I want it to install an MSI.  What is the best way to do this.  VBScripting or GPO logon check?  Please give me an example of a script if you have one.  Or a link
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


I created a little script that will go out and check to see if a particular application is installed on a computer. First I will show the full VBS script, then go over some modifications you might have to make.

As you will notice, I'm dumping the results of the script in C:\WINDOWS\system32\temp\ You may change this directory to any other location.

Also, you will need to change the line Microsoft .NET Framework 2.0. This is an example where I was checking to see if Microsoft .NET Framework 2.0 was installed. You will want to change this value to the application you are looking for.

Another area where you can get really creative with the script is the IF ELSE statement.

Currently I put echo statements in there as a template. Most likely I would have this statement do the action I wanted if the application was found such as uninstall or add additional files.

Check if it helps
'This script outputs to a .tsv file a list of applications installed on the computer
'Output file is software.tsv
'Usage: cscript applications.vbs

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("C:\WINDOWS\system32\temp\software.tsv", True)

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
  & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
  ("Select * from Win32_Product")

objTextFile.WriteLine "Caption" & vbtab & _
  "Description" & vbtab & "Identifying Number" & vbtab & _
  "Install Date" & vbtab & "Install Location" & vbtab & _
  "Install State" & vbtab & "Name" & vbtab & _ 
  "Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _
    & "Version" 

For Each objSoftware in colSoftware
  objTextFile.WriteLine objSoftware.Caption & vbtab & _
  objSoftware.Description & vbtab & _
  objSoftware.IdentifyingNumber & vbtab & _
  objSoftware.InstallDate2 & vbtab & _
  objSoftware.InstallLocation & vbtab & _
  objSoftware.InstallState & vbtab & _
  objSoftware.Name & vbtab & _
  objSoftware.PackageCache & vbtab & _
  objSoftware.SKUNumber & vbtab & _
  objSoftware.Vendor & vbtab & _

'This searches for a string of txt in a file

Dim FoundIt  'as boolean
FoundIt=false  'initialize it to false
With createobject("Scripting.FileSystemObject")
  on error resume next
  FoundIt = (InStr(1,.OpenTextFile("C:\WINDOWS\system32\temp\software.tsv",1,true,-2).ReadAll,"Microsoft .NET Framework 2.0",1) <> 0)
  on error goto 0
End With

'wscript.echo FoundIt

If FoundIt Then
  wscript.echo "true"
  wscript.echo "false"
End If

Open in new window

gatoraidabAuthor Commented:
I was reading your script and I love it.  One thing though.  Currently you just have it say "False" if the application isn't installed.  How do I put it so that it installs the application if not installed.
gatoraidabAuthor Commented:
Do you think this code will work properly in a logon script?

strRem2 = "\\servername\sharename\program.msi /qn"
intError = 0
    Set objProcess = objWMIService.Get("Win32_Process")
    Set objProgram = objProcess.Methods_("Create").InParameters.SpawnInstance_
    objProgram.CommandLine = strRem2
    Set strShell = objWMIService.ExecMethod("Win32_Process","Create",objProgram)
    WScript.Echo Now & " " & strPCName & " start installer intError reports as " & intError
    If Not Err = 0 Then
        LogFile.WriteLine "," & Now & ",Error: Could not start Installer on," & strPCName
        LogFile.WriteLine "," & Now & ",Run Tuner Installer Started on," & strPCName
    '    WScript.Sleep(JobSleep)
    End If  'intError = 0

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gatoraidabAuthor Commented:
Great script, worked as intended.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Server Apps

From novice to tech pro — start learning today.