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

Run an Executable with vbScript 1

Status
Not open for further replies.

scantron

Programmer
Jul 4, 2002
27
CA
Hi,

I simply need to know how to run an exe, bat file or autorun file. I'm sure no expert and I'm just learning as I go here. This is an executable vbScript file that is not used within a web page. Just opens and runs within Windows, using Windows commands.

So if anyone knows the syntax to open a file, something like:

run (filename)

or whatever it is, that would be awesome!

Thanks all

Scantron
 
Set oWsh = CreateObject("WScript.Shell")
oWsh.Run("Notepad.exe")

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Hey Tom,

Thanks for your help. I tried that and nothing seemed to happen. I've alread had an instance of WScript.Shell defined. I added in the .run code and it hasn't executed anything. Seems to just skip it.

Any ideas? The executable (.bat) is in the same directory as the vbScript, so I wrote it: oWsh.Run("FileName.bat")

Thanks again

Scantron
 
Try:
oWsh.Run("cmd /K FileName.bat")


[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Try:
oWsh.Run("cmd /K FileName.bat", 3, True)


[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Yeah it works. I had jus screwed it up is all.

Thanks alot

Happy Independance Day or Canada day if you live in either.

Scantron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top