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!

Check for a file to exist first 2

Status
Not open for further replies.

ALLM

Technical User
Aug 11, 2009
14
US
I'm running this script to kick this .exe of for a silent uninstall. I need it do a check first to see if the .exe exists and if not then QUIT, but if it does then call out the .exe in the path below.

Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run "c:\windows\system32\iprint\setupipp.exe /U /S /R", 6, True
set wshshell = nothing

I'm knew to working with VBS so any help would be greatly appreciated.

Thanks.
 
Dir() function returns the file name from a path if the file exists. Returns blank if not...

Code:
Set wshShell = WScript.CreateObject ("WSCript.shell")

If Dir("c:\windows\system32\iprint\setupipp.exe")<>"" Then
wshshell.run "c:\windows\system32\iprint\setupipp.exe /U /S /R", 6, True
End If
set wshshell = nothing
 
[tt]sfile="c:\windows\system32\iprint\setupipp.exe"
if createobject("scripting.filesystemobject").fileexists(sfile) then
Set wshShell = WScript.CreateObject ("WScript.shell")
wshshell.run sfile & " /U /S /R", 6, True
set wshshell = nothing
end if[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top