We help IT Professionals succeed at work.
Get Started

VBS TO CLOSE APPS AND THEN OPEN IMAGE

370 Views
Last Modified: 2014-08-21
Trying to get this vbs to close all apps, but then open an image at end.   Everything closes just fine, except it doesn't open the image

Any idea how to work around it?

Option Explicit
Dim objWMIService, objProcess, colProcess
Dim xComputer, xProcessKill, xProcessKill2, xProcessKill3, xProcessKill4, xProcessKill5, xProcessKill6, xProcessKill7, xProcessKill8, xProcessKill9, xProcessKill10
xComputer = "."
xProcessKill = "'excel.exe'"
xProcessKill2 = "'outlook.exe'"
xProcessKill3 = "'winword.exe'"
xProcessKill4 = "'powerpnt.exe'"
xProcessKill5 = "'onenote.exe'"
xProcessKill6 = "'iexplore.exe'"
xProcessKill7 = "'notepad.exe'"
xProcessKill8 = "'wordpad.exe'"
xProcessKill9 = "'mstsc.exe'"
xProcessKill10 = "'wfica32.exe'"

 
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _ 
& xComputer & "\root\cimv2") 
 
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill)
On Error Resume Next
For Each objProcess in colProcess
objProcess.Terminate()
Next 
 
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill2)
On Error Resume Next
For Each objProcess in colProcess
objProcess.Terminate()
Next 
 
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill3)
On Error Resume Next
For Each objProcess in colProcess
objProcess.Terminate()
Next
 
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill4)
On Error Resume Next
For Each objProcess in colProcess
objProcess.Terminate()
Next
 
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill5)
On Error Resume Next
For Each objProcess in colProcess
objProcess.Terminate()
Next
 
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill6)
On Error Resume Next
For Each objProcess in colProcess
objProcess.Terminate()
Next
 
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill7)
On Error Resume Next
For Each objProcess in colProcess
objProcess.Terminate()
Next
 
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill8)
On Error Resume Next
For Each objProcess in colProcess
objProcess.Terminate()
Next

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill9)
On Error Resume Next
For Each objProcess in colProcess
objProcess.Terminate()
Next

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill10)
On Error Resume Next
For Each objProcess in colProcess
objProcess.Terminate()
Next

--- OPEN IMAGE HERE
Set objExplorer = CreateObject("InternetExplorer.Application")
With objExplorer
    .Navigate "about:blank"
    .Visible = 1
    .Document.Title = "Show Image"
    .Toolbar=False
    .Statusbar=False
    .Top=1400
    .Left=1400
    .Height=900
    .Width=700
    .Document.Body.InnerHTML = "<img src='\\EPICAZO\PersonalWork\DOWNTIME FLYER 08182014 V1_SM.png'>"
End With

OR

CreateObject("WScript.Shell").Run "\\EPICAZO\PersonalWork\DOWNTIME FLYER 08182014 V1_SM.png"

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE