09/24/2009 2310 views
Hi All

I am looking to put a VBScript into a few of my virtual applications that will look for an exe on a server and if it finds it then it needs to run the exe, but if it cant find it then it needs to launch the app anyway. Any help would be greatly appreciated.

0 Comments   [ + ] Show comments


Community Chosen Answer

Here's the bones of the logic you're looking for.

Set objfso = wscript.createobject("scripting.filesystemobject")

if objfso.fileexists("\\SERVER\SHARE\FILE.EXT") Then
' Do Something here
' Do Something Else here
End If

This may be presumptuous, but I assume you already know how to set up a shell object to run whatever commands it is you're going to be running. This is just the If/Then to look for a file and then do something.
Answered 09/24/2009 by: Jsaylor
Second Degree Blue Belt

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

All Answers

It would be valuable for you to attempting doing some basic searches and attempting to write a script before posting.

You want to see if a file"exists" then "run" that executable, else "run" the app anyway.

Focus on each part of the script and make something that does each part. (Exist & objShell.Run) - almost made you find the objShell part of that.
Then mash them together.

Go to the microsoft scripting guys web page and download the portable script center, where you can search for important terms, and build a script around that.
Good luck,
Answered 09/24/2009 by: bkruiser
Orange Belt

Sorry J,

not sure what you mean by setting up a shell object?

I've got the whole find the file logic and can find it, but not sure how to tell it to launch the exe if it can find it. Also not to sure what the syntax is to say "If you cant find the file just do nothing and carry on launching the application" thats what I seem to be struggling on. Sorry to come across a dork but havent been doing scripting very long
Answered 09/24/2009 by: earthworm jim
Senior Yellow Belt

Here's the other portion of the script that you'd be looking for, this will run a command of your choosing. see if you can put the whole thing together the right way and see what you come up with.

Set WshShell = wscript.createobject("wscript.shell")

wshshell.run "C:\INSERT\PROGRAM\HERE.EXT",1,true

Answered 09/24/2009 by: Jsaylor
Second Degree Blue Belt