Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 23rd, 2003, 01:56 PM
Authorized User
 
Join Date: Oct 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Execute .exe file and terminate it

Hey guys...

I need help here. I am trying to execute an .exe file in my server from an ASP page with some parameters.

This is how I execute it in DOS:
Code:
c:\prog~1\myfolder\MyEXEProg.EXE /CC /RSomeAutoGenNumber /T1212;
I found couple of snippet in this and other forum, but it doesn't seem to work (or does it?) I tried the codes below:
Code:
<%

Dim ToRun_Prog_SCmd, ExecRunCmd 
Set ToRun_Prog_SCmd = Server.CreateObject("WScript.Shell")
'ToRun_Prog_SCmd.Run "http://webserver/myfolder/MyEXEProg.EXE /CC /RJ7H1JHHJHAZNXZNN /T1212;"
ExecRunCmd = ToRun_Prog_SCmd.Run ("http://webserver/myfolder/MyEXEProg.EXE /CC /RJ7H1JHHJHAZNXZNN /T1212;", 6, True)
Set ToRun_Prog_SCmd = Nothing

%>
I try to open it on my browser, it just keeps saying 'Waiting to connect to webserver' with nothing being displayed which I usually terminate it right away. I do not know if it is executing my file or not.

So, how should I do my DOS command(with the parameters) so it will be executed from my ASP page?

One other thing, how to set a timeout for my web page to try executing my application? So, it wont keep on executing after, let's say, 10 seconds.

Thank in advance for your time and I hope to hear from you guys soon...



« Wayang Mßeling »
÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷ ÷÷÷÷÷
ASP Newbie need guidances here
__________________
« Wayang Mßeling »
÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷ ÷÷÷÷÷
ASP/PHP Prog. Wannabe needs guidances here
 
Old October 24th, 2003, 05:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

You need to use the local path (c:\blahblah not http://blahblah) when you call the run command. Make sure the anon user has permissions to the folder where the exe is (assuming your asp runs under the anon user).
 
Old October 24th, 2003, 11:13 AM
Authorized User
 
Join Date: Oct 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey pgtips...thanks for the reply.

I tried what you suggested and it is somewhat working. What I mean is that it opened the exe program that is called from my ASP page (since there is a DOS console came up dan then gone). However, it did not write anything to the text file as it has to be.

The .exe program is supposed to generate a key and write that just-generated key to the text file (as it is executed from DOS). After I execute my program from the ASP, I checked the text file, but the text file has not changed.

I am using PWS, and I set the permission of the folder where my program and ASP pages located (and other folders that are related too) to be able to Read, Execute and to use Script. I hope that is what you mean since that is the only thing I can do from the Personal Web Manager console and I dont see the option where I can change properties for Anon or other users.

One other thing, by changing http://blablabla to c:\wwwroot\folder\, I wonder, does the program run in my local machine or in my server? if I move the site to my production server, should I keep it as c:\blablabla or should I change it back to http://blablabla? Sorry if the questions sounds silly...just want to make sure.

Thank you and I am sorry if I ask too much. Hope to hear from you again soon. :D



« Wayang Mßeling »
÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷ ÷÷÷÷÷
ASP Newbie needs guidances here
 
Old October 24th, 2003, 11:57 AM
Authorized User
 
Join Date: Oct 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oh NOOOO...

I made mistake on my first posting in my DOS command. I left out the 'START' word in it. so, it should be:

c:\prog~1\myfolder>START MyEXEProg.EXE /CC /RSomeAutoGenNumber /T1212;

instead of just:

  c:\prog~1\myfolder\MyEXEProg.EXE /CC /RSomeAutoGenNumber /T1212;

with that mistake, is there anything in my code below needed to be changed?

  ExecRunCmd = ToRun_Prog_SCmd.Run ("c:\webserver\myfolder\MyEXEProg.EXE /CC /RJ7H1JHHJHAZNXZNN /T1212;", 6, True)





« Wayang Mßeling »
÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷ ÷÷÷÷÷
ASP Newbie needs guidances here
 
Old October 27th, 2003, 08:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:After I execute my program from the ASP, I checked the text file, but the text file has not changed.
Maybe the anonymous user doesn't have permissions to write to the folder where the text file is located. see below

Quote:
quote:I am using PWS, and I set the permission of the folder where my program and ASP pages located (and other folders that are related too) to be able to Read, Execute and to use Script. I hope that is what you mean since that is the only thing I can do from the Personal Web Manager console and I dont see the option where I can change properties for Anon or other users.
I'm talking about Windows permissions here. By default, all ASP pages run under a special anonymous user called IUSR_<<machineName>>. That is the user I'm referring to. To check permissions, from Windows Explorer right-click the folder where the text file will be created, choose properties and take a look at the Security tab. Make sure IUSR_<<machineName>> is in the list of users and add it if not.

Quote:
quote:One other thing, by changing http://blablabla to c:\wwwroot\folder\, I wonder, does the program run in my local machine or in my server? if I move the site to my production server, should I keep it as c:\blablabla or should I change it back to http://blablabla? Sorry if the questions sounds silly...just want to make sure.
No you should keep it as c:\blahblah (it always runs on the server not the client, because the ASP page always runs on the server). Have you considered what will happen if 2 or more people access this ASP page at the same time? Will they both be trying to write to the same text file? Could be problems...

hth
Phil
 
Old October 28th, 2003, 09:23 PM
Authorized User
 
Join Date: Oct 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Phil...

It works...I have changed (mostly) the folders permission so that they can Run, Execute and Script things. And also set some related files as "Archive" so it can be Read/Write.

The problem with the "Write" thing is caused by the .exe file that I want to execute. It does not create the file in the specific folder, so it looks like my script was looking at the wrong file while the program write it on the other file. So, when I found the wanted file, I just changed the file-to-read path location in my script so it points to that file.

I am aware about the problem you mentioned when more than one user trying to accesss/write to the file at the same time. In the future, the other guy will change the .exe file so that it will generate different text file for different user.

Thanks once again Phil...you and this forum really help.


« Wayang Mßeling »
÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷ ÷÷÷÷÷
ASP Newbie needs guidances here
 
Old December 2nd, 2003, 04:57 PM
Registered User
 
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scotp58
Default

I'm having a similar problem running a .bat file on the server. With the ASP code below, I don't get any errors, the .bat file is created correctly, but it does not execute. If I run the same code (with the "Server." removed from the CreateObject(s)), it runs fine AND executes the .bat file. The 'Internet Guest Account' has Read & Execute/Read/Write permissions on the .bat file. Running ASP 5.0 on Win2k server.

<%
Dim fso
Dim agentPath, agentName, agentRunFile
Dim agentRunTime
Dim runString

agentPath="E:\sjp"
agentName="agntTest01.vbs"
agentRunFile="agnt01.bat"
agentRunTime=DateAdd("n", 2, Now())
runHr=DatePart("h", agentRunTime)
runMin=DatePart("n", agentRunTime)
If runMin<10 Then runMin="0" & runMin
agentRunTime=runHr & ":" & runMin
runString="AT " & agentRunTime & " cscript.exe " & Chr(34) & agentPath & "\" & agentName & chr(34)
Set fso=Server.CreateObject("Scripting.FileSystemObjec t")

Set runFile=fso.CreateTextFile(agentPath & "\" & agentRunFile,True)
runFile.Write(runString)
runFile.Close()
Set runFile=nothing
Set fso=nothing

set wshell = Server.CreateObject("WScript.Shell")
wshell.run "E:\sjp\agnt01.bat"
set wshell = nothing
%>
 
Old December 3rd, 2003, 05:01 PM
Registered User
 
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scotp58
Default

Should read:
... If I run the same code (with ...) ON THE SERVER,...

 
Old February 26th, 2005, 01:58 AM
Registered User
 
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Wayang_Mbeling
 Hey guys...

I need help here. I am trying to execute an .exe file in my server from an ASP page with some parameters.

This is how I execute it in DOS:
Code:
c:\prog~1\myfolder\MyEXEProg.EXE /CC /RSomeAutoGenNumber /T1212;
I found couple of snippet in this and other forum, but it doesn't seem to work (or does it?) I tried the codes below:
Code:
<%

Dim ToRun_Prog_SCmd, ExecRunCmd 
Set ToRun_Prog_SCmd = Server.CreateObject("WScript.Shell")
'ToRun_Prog_SCmd.Run "http://webserver/myfolder/MyEXEProg.EXE /CC /RJ7H1JHHJHAZNXZNN /T1212;"
ExecRunCmd = ToRun_Prog_SCmd.Run ("http://webserver/myfolder/MyEXEProg.EXE /CC /RJ7H1JHHJHAZNXZNN /T1212;", 6, True)
Set ToRun_Prog_SCmd = Nothing

%>
I try to open it on my browser, it just keeps saying 'Waiting to connect to webserver' with nothing being displayed which I usually terminate it right away. I do not know if it is executing my file or not.

So, how should I do my DOS command(with the parameters) so it will be executed from my ASP page?

One other thing, how to set a timeout for my web page to try executing my application? So, it wont keep on executing after, let's say, 10 seconds.

Thank in advance for your time and I hope to hear from you guys soon...



« Wayang Mßeling »
÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷ ÷÷÷÷÷
ASP Newbie need guidances here
 
Old October 18th, 2005, 02:42 AM
Registered User
 
Join Date: Oct 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default


exe file is in D:\programs\fabmsgsnd.exe.

It should call this exe file awhen i click the some command button called config.

can any tell the script for calling this from the asp page.

Thanks in advance.

R.Sriram





Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute .exe file and terminate it courseware ASP.NET 1.0 and 1.1 Basics 1 March 13th, 2006 02:08 AM
Execute .exe file and terminate it courseware Classic ASP Basics 0 November 9th, 2005 02:49 PM
execute exe file from web shinedas ASP.NET 1.0 and 1.1 Basics 1 November 9th, 2005 03:07 AM
To execute an exe file from an asp page. sree_mig Classic ASP Basics 0 October 18th, 2005 04:43 AM
How to Execute and EXE file through ASP rekha_jsr Classic ASP Basics 6 November 16th, 2004 05:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.