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

Executing an .exe with vbscript

Status
Not open for further replies.

at51178

Technical User
Joined
Mar 25, 2002
Messages
587
Location
US
Hey guys

I am new to vbscript

but what I am looking to do is to open an .exe file using vbscript but I have been on some of the sites about vbscript and i can't find any information that makes sense or works can you someone help me with this or give me a link to a website that may help
 
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("notepad.exe", 1, True)
 
saying that you might need to get rid of the ()


Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad.exe", 1, True
 
Sorry but it wasn't a .exe as I thought originally it is a file ending in the extension .edp

any one familliar with this.
 
do you want to run this file or read this file?
if you want to run the file use the Run method
this might work if the file is already associated with an installed application

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "c:\win\file.edp", 1, True

If you want to read the file like you would a text file then
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set tsFile = FSO.OpenTextFile("c:\win\file.edp", 1)
Do while Not tsFile.AtEndOfStream
msgbox tsFile.ReadLine
Loop
tsFile.Close
Set tsFile = Nothing

if you need to open this edp file with another application something like this might work

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "c:\win\edpapplication.exe c:\win\file.edp", 1, True
 
i'm trying to do the same with this
Dim wshshell
Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run "W:\harrisoj\jcltest.exe"

i'm getting a runtime error -

error: Object required 'wscript'

the debugger is pointing to the set...HELP!!!
 
I found that is you took out the path name and only the name of the file it runs fine
 
i've tried it and got the same error...
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run "jcltest.exe"
 
What is the container of your script ?
The example posted assumes a .VBS file run by cscript or wscript.
You may try this:
Code:
Set WshShell=CreateObject("WScript.Shell")
WshShell.Run "W:\harrisoj\jcltest.exe"


Hope This Help
PH.
 
this is all my script...the file name is chkboxes.htm...
<HTML>

<FONT FACE=&quot;arial&quot; SIZE=2>
<CENTER>
<IFRAME FRAMEBORDER=0 src=&quot;/harrisoJ/dcadsplash.jpg&quot; border=&quot;0&quot; style=&quot;height:300px;width:775px;&quot;>
</IFRAME>
<CENTER>
<H4>BATCH ENTERPRISE MARS<BR>
Daily Stand Alone</H4>

<SCRIPT LANGUAGE=&quot;vbscript&quot;>


Sub cmdButton1_OnClick
Dim x
For x = 0 to 6
Document.frmMyForm.Elements(x).Checked = True
Next
End Sub

Sub cmdButton2_OnClick
Dim x
For x = 0 to 6
Document.frmMyForm.Elements(x).Checked = False
Next
End Sub

Sub cmdButton4_ONClick
Dim MFTEST
MFTEST = &quot;FREDjgh&quot;
MsgBox(MFTEST)

Set WshShell=CreateObject(&quot;WScript.Shell&quot;)
WshShell.Run &quot;W:\harrisoj\jcltest.exe&quot;

End Sub

</SCRIPT>
</HEAD>

<BODY BGCOLOR=&quot;gray&quot;>
<FORM NAME=&quot;frmMyForm&quot;>
<TABLE>
<TD>PRDJ196D<TD><INPUT TYPE=&quot;checkbox&quot; NAME=&quot;chk1&quot; VALUE=&quot;One&quot;><TR>
<TD>PRDJREVW<TD><INPUT TYPE=&quot;checkbox&quot; NAME=&quot;chk2&quot; VALUE=&quot;Two&quot;><TR>
<TD>PRDJRVFR<TD><INPUT TYPE=&quot;checkbox&quot; NAME=&quot;chk3&quot; VALUE=&quot;Three&quot;><TR>
<TD>PEDJEXLT<TD><INPUT TYPE=&quot;checkbox&quot; NAME=&quot;chk4&quot; VALUE=&quot;Four&quot;><TR>
<TD>PBDJLEWS<TD><INPUT TYPE=&quot;checkbox&quot; NAME=&quot;chk5&quot; VALUE=&quot;Five&quot;><TR>
<TD>PXDJSFDR<TD><INPUT TYPE=&quot;checkbox&quot; NAME=&quot;chk6&quot; VALUE=&quot;Six&quot;><TR>
<TD>PXDJXEMN<TD><INPUT TYPE=&quot;checkbox&quot; NAME=&quot;chk7&quot; VALUE=&quot;Seven&quot;><TR>
</TABLE>
<INPUT TYPE=&quot;button&quot; NAME=&quot;cmdButton1&quot; VALUE=&quot;Select all &quot;>
<INPUT TYPE=&quot;button&quot; NAME=&quot;cmdButton2&quot; VALUE=&quot;Deselect &quot;>
<INPUT TYPE=&quot;button&quot; NAME=&quot;cmdButton3&quot; VALUE=&quot;Run All Jobs&quot;>
<INPUT TYPE=&quot;button&quot; NAME=&quot;cmdButton4&quot; VALUE=&quot;Run Selected&quot;>


</FORM>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top