[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

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
  • 3
1 Solution

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

gatoraidabAuthor Commented:
Great script, worked as intended.

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now