Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with Windows 7 finding installed VNC

Status
Not open for further replies.

SausageSie

Technical User
Jun 21, 2006
4
GB
Basically I am installing VNC using GP startup.

I have to do it this way as the mis requires a restart and this can not be done by deployment. Anyway. Its works fine in XP but win7 machine just loop. So I must be missing something. Am I using the correct way to look for the app or should I use reg? my code is below.

Cheers


Option Explicit 'Forces variables to be declared

'Define constants

'Declare variables
Dim strComputer
Dim objWMIService
Dim colSoftware
Dim objSoftware
Dim retCode
Dim WshShell

'Set variables
strComputer = "."

'Create objects
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where PackageName = '*VNC'")
WScript.Echo ("Select * from Win32_Product Where PackageName = '*VNC'")
On Error Resume Next

'Searchs installed programs
For Each objSoftware In colSoftware
WScript.Echo "test quit"
WScript.Quit
Next

'Pause for a period of time
'WScript.Sleep(30000) ' This is 30 seconds

'Installs new EXE from network share
retCode = WshShell.Run("\\Server\VNC\x86\UltraVNC.msi", 0,True) '0 hides window
 
sorry the last line is as follows
retCode = WshShell.Run("\\ni-bf-app-01\VNC\x86\UltraVNC.msi /silent /forcerestart", 0,True) '0 hides window

i removed some commands for testing
 
1) I think there's a problem with your WMI query...
2) You may need to run MSIExec instead of just pushing the file. (switch to quiet when you're convinced things are working)

Code:
Option Explicit 'Forces variables to be declared 
  
'Declare variables 
Dim strComputer, objWMIService, colSoftware, objSoftware, retCode, WshShell
Dim bolInstalled  

'Set variables 
strComputer = "." 
[blue]bolInstalled = False[/blue]
  
'Create objects 
Set WshShell = WScript.CreateObject("WScript.Shell") 
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set colSoftware = objWMIService.ExecQuery("Select * from Win32_Product Where [blue]Name like '%VNC%'")[/blue]

'Searchs installed programs
For Each objSoftware In colSoftware 
[blue]'     WScript.Echo objSoftware.Name
    bolInstalled = True[/blue]
Next 
  
'Pause for a period of time 
'WScript.Sleep(30000) ' This is 30 seconds 
  
'Installs new EXE from network share 
[blue]If bolInstalled = False Then[/blue]
	retCode = WshShell.Run("[blue]msiexec /i /passive /forcerestart[/blue] ""\\Server\VNC\x86\UltraVNC.msi""", 0,True) '0 hides window
[blue]End If[/blue]

PSC
[—] CCNP[sub][blue]x3[/blue][/sub] (Security/R&S/Wireless) [•] MCITP: Enterprise Admin [•] MCSE [—]

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --from "Hackers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top