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

VBscript code to let me point to a executable on my server

Status
Not open for further replies.

vemate

Programmer
Aug 23, 2002
61
US
<! This script executes Forest Products Accounting from the Intranet WEB>
<Input language="VBScript" type="Button" value="Click FPA System" onclick="ExecHTA()">
<Script language="VBScript">
' Public Object so i dont have to keep making them
'and they are separated by subs or functions
<!--------------------------------------------------------------->
Public w
Set w = CreateObject("WScript.Shell")
Sub ExecHTA()
w.Exec("mshta F:\TZO\FPAWEB.TZO.COM\OLM_DOWNLOAD\simple.hta")
End Sub
<!--------------------------------------------------------------->
This shell code calls a hta file from my web site but the path is lost and I cannot execute the program. I am no expert with vbscript. I need a way to make sure my path is pointing to my F: drive which is the drive my Web site runs the executables from. I am using hta which is a html program that allows execution with html. I would appreciate code to show me how to set my data path correctly.

Thank you very much.
 
The first thing I would try is changing this line:
w.Exec("mshta F:\TZO\FPAWEB.TZO.COM\OLM_DOWNLOAD\simple.hta")

to:
w.Exec("F:\TZO\FPAWEB.TZO.COM\OLM_DOWNLOAD\simple.hta")
 
When I changed to this
w.Exec("F:\TZO\FPAWEB.TZO.COM\OLM_DOWNLOAD\simple.hta")
the program would not run at all.
 
Try this code and tell me if there are any errors reported in the MsgBox's:

Code:
?<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="GENERATOR" Content="Microsoft Visual Studio">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8">
<script id=clientEventHandlersVBS language=vbscript>
<!--

Sub Button1_onclick
	Dim w 
	On Error Resume Next
	Set w = CreateObject("WScript.Shell")
	MsgBox Err.Description
	w.Exec("mshta F:\TZO\FPAWEB.TZO.COM\OLM_DOWNLOAD\simple.hta
	MsgBox Err.Description
End Sub

-->
</script>
</HEAD>
<BODY>

<!-- Insert HTML here -->
 <input id=Button1 type=button value=Button>

</BODY>
</HTML>
 
<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="GENERATOR" Content="Microsoft Visual Studio">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8">
<script id=clientEventHandlersVBS language=vbscript>
<!--

Sub Button1_onclick
Dim w
On Error Resume Next
Set w = CreateObject("WScript.Shell")
MsgBox Err.Description
w.Exec("mshta F:\TZO\simple.hta MsgBox Err.Description")
End Sub

-->
</script>
</HEAD>
<BODY>

<!-- Insert HTML here -->
<input id=Button1 type=button value=Button>

</BODY>
</HTML>
Please check this I get no errors. I shortened the path so it would be no confusion. The box appears and when I click nothing.
 
I lied now it is working. It says vb script.
sorry about that.
 
THis line would be a problem:
w.Exec("mshta F:\TZO\simple.hta MsgBox Err.Description")

Is this just a typo or is this really the way you have it?
 
<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="GENERATOR" Content="Microsoft Visual Studio">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8">
<script id=clientEventHandlersVBS language=vbscript>
<!--

Sub Button1_onclick
Dim w
On Error Resume Next
Set w = CreateObject("WScript.Shell")
MsgBox Err.Description
w.Exec("mshta F:\TZO\simple.hta MsgBox Err.Description")
End Sub

-->
</script>
</HEAD>
<BODY>

<!-- Insert HTML here -->
<input id=Button1 type=button value=Button>

</BODY>
</HTML>
 
Change THis:
w.Exec("mshta F:\TZO\simple.hta MsgBox Err.Description")

To THis:
w.Exec("mshta F:\TZO\simple.hta")
MsgBox Err.Description
 
ActiveX components can't create object .
Object required.
 
I don't know exactly what the problem is then. The code I posted worked fine on my box and opened an hta on a mapped directory on a server. If you take just the code to open the hta and put it into a vbscript, does it work then?
 
When I call the HTA to run my program F:\tzo\fpa\aas2.exe
It attempts to run but it cannot locate aas2.exe it cannot find the program. It is like the path is gone or corrupted.
 
I'm confused. This is what it seems like you are doing:

You have an HTML with a button on it. Clicking the button starts an HTA that resides on a server. This HTA kicks off an exe that lives somewhere else on the same server. Is this correct?
 
Thats right the HTML Button is the VBscript shell that calls the HTA that executes the program aas2.exe on the same server. Microsoft says you have to run this script to run a HTA is this not correct? This is my first time to try to run a HTA. I want the program to run not copy to my desk top and then run.
 
Ok, it sounds like you have path issues. What is the path to each of the server side items?
 
My server is the F: Drive.
My programs and data are stored in one folder FPA on the F: Drive
I run aas2.exe which is my main program menu it resides inside of the FPA folder on F: Drive.
They all reside on one server Drive F:

My main menu F:\tzo\fpa\aas2.exe is what I am trying to execute. This is kinda confusing I apologize. When I try to execute the program it cannot find the path. I store the data path in a aas.ini file in windows folder. This tells me where my data files are located.
 
Ok, what is dose the line of code that executes aas2.exe look like?

Also, do you know that aas2.exe is designed to run from a server and not locally?
 
Yes the programs are C++ and they run from a Server now.
to run FPA I create a Icon on your desktop that runs the programs. I call f:\fpa\aas2.exe from the Icon.
 
It is I was just telling you how I normally run the Programs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top