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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Installing setup after closing iexplore.exe

Status
Not open for further replies.

Trenchie

Technical User
Apr 12, 2012
1
0
0
GB
Hi

I'm new to Vbscripting and might have taken on more than i can chew and wondering if anyone can help

I'm trying create a Vbscript that installs Adobe Shockwave.
This is being deployed to users who i would like to have a less interaction as possible

However when i install it, it fails as Internet explorer is open.

What i need a script to do is

First detects if internet explorer is running
If not then the setup will install
If it is open and a message box will pop up stating that the setup is about to install and to close internet explorer. This will then give them an option to (Yes,No)
If they click YES it will prompt (again Message box) to close internet explorer (Which they will do have to do manually) I then want it to detect that internet explorer has closed. Once it is closed it will and carry on with the install.
If they click NO. I want it to either stop the install and to run the script daily until they shockwave is install Shockwave.
Or to send a pop up message to the user stating that Shockwave will be installed next time Internet Explorer is closed.
There will be a loop checking if internet has closed once it detects it has closed it will continue to install the setup. (I'm thinking this will take alot of the processor up)

Thanks if you can help
 
The function below should return true or false depending on if IE is running.

Code:
Function IEIsRunning(strComputer)
	Dim objWMIService, objProcess, colProcess
	IEIsRunning = False

	Set objWMIService = GetObject("winmgmts:" _
		& "{impersonationLevel=impersonate}!\\" _
		& strComputer & "\root\cimv2")
	
	Set colProcess = objWMIService.ExecQuery _
		("Select * from Win32_Process")
	
	For Each objProcess in colProcess
		If LCase(objProcess.Name) = "iexplore.exe" Then
			IEIsRunning = True
			Exit For
		End If
	Next
End Function

Pseudocode for the rest of the script would look something like this:
Code:
Option Explicit
Dim strComputer
strComputer = "."

Do While IEIsRunning(strComputer)
   [COLOR=blue]msgbox with yes/no question
   if user chose "no" then wscript.quit[/color]
Loop

[COLOR=blue]run the installer[/color]
 
HI Try this script !
Code:
Function IEIsRunning(strComputer)
    Dim objWMIService, objProcess, colProcess
    strComputer = "."
    IEIsRunning = False
 Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" _
        & strComputer & "\root\cimv2")
    
    Set colProcess = objWMIService.ExecQuery _
        ("Select * from Win32_Process")
    
    For Each objProcess in colProcess
        If LCase(objProcess.Name) = "iexplore.exe" Then
        IEIsRunning = True
Question = msgbox("CAUTION ! Internet Explorer is under execution !"&vbcr&_
"you must close all instances of Internet Explorer to continue the installation of shockwave !"&vbcr&_
"Thank you !",vbYesNo+VbQuestion,"Internet Explorer is under execution")
   If Question = VbYes Then
   KillProcess("iexplore.exe")
    Exit For 
   Else
   wscript.Quit 
   end if     
        End If
    Next
End Function

Function KillProcess(ProcessNames)
Set ws = CreateObject("wscript.shell")
Ws.Run "cmd /C taskkill /f /im "&ProcessNames&"",0,TRUE
End Function

Sub Installation_ShockWave()
MsgBox "Installation of Shockwave",64,"Installation of Shockwave"
end Sub

Do while IEIsRunning(strComputer)
wscript.sleep 5000
Loop

Call Installation_ShockWave()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top