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

objWshShell.run obly works for exe's

Status
Not open for further replies.

dr350

Programmer
Oct 17, 2008
1
CA


Hello

I am trying to use the objWshShell.run command to execute an ade file.

iReturn = objWshShell.run("C:\abcd.ade")

when I run the vbs script nothing happens, no error msgs or ade running.

when I use the same script with the following line
iReturn = objWshShell.run("abcd.exe")

notepad runs

I have also tried to execute a spreadsheet from the C drive with no luck.
iReturn = objWshShell.run("abcd.xls")

abcd.exe
abcd.ade
abcd.xls
exist on C:\

below is my script

Option Explicit
'-------------------------------------------------------------
' Mainline
'-------------------------------------------------------------
Dim objWshShell, iReturn, sRunCommand

' create a shell object
Set objWshShell = WScript.CreateObject("WScript.Shell")

iReturn = objWshShell.run("notepad.exe")
if iReturn <> 0 then
i = msgbox ("Error starting application. " & vbnewline & sRunCommand _
& vbnewline & "Return code = " & cstr(iReturn),,"WScript.ScriptFullName")
end if

' cleanup

set objWshShell = Nothing


wscript.quit(0)





thanks for any replies
 
You need to launch whatever program the ade file is associated with and pass the file name as an argument to that programs executable.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top