/build/static/layout/Breadcrumb_cap_w.png

Help Needed with VBScripting

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.

thanks

0 Comments   [ + ] Show comments

Answers (4)

Posted by: Jsaylor 14 years ago
Second Degree Blue Belt
1
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
Else
' 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.
Posted by: bkruiser 14 years ago
Orange Belt
0
Earthworm,
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,
Brian
Posted by: earthworm jim 14 years ago
Senior Yellow Belt
0
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
Posted by: Jsaylor 14 years ago
Second Degree Blue Belt
0
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

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ