Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Running a batch from ASP

Posted on 2006-12-01
6
Medium Priority
?
262 Views
Last Modified: 2010-04-06
Below is my code for running a batch/exe from within ASP

-->
dirPath = server.mappath(".")
dirPath = dirPath & "\update.exe"
response.write dirPath

Set WShShell = Server.CreateObject("WScript.Shell")

RetCode = WShShell.Run(dirPath,10,true)

Set WShShell = Nothing
<--

When I run this it appears to do nothing - I ran it multiple times.   Then it dawned on me to check Task Manager for Processes running.   I'll be darned if there weren't multiple instances of that executable running owned by the IWAM user, but within the asp it never appeared to do anything or actually open the executable.    I also switched update.exe to a batch that simple opened notepad.exe and got the same result.   Any idea what I'm missing to make this execute properly?  

Thanks
0
Comment
Question by:acco_is
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:walkerke
ID: 18057052
What is your objective with this script?

ASP is for processing scripts, usually VBScript, which generate HTML for IIS to serve to a web browser. The response.write command above will return the directory path to the output stream to be displayed by the requesting web visitor. The script will launch update.exe to run in the current user space which, if launched by IIS, is IWAM_servername. If you could log in as IWAM_servername, you'd find the updater running there.

If you log into the server and double-click the script locally, it should launch updater.exe in the logged in user space. I'm not sure what VBScript would do with the response.write command, though. I think that's strictly an ASP command. You'd need something like a prompt command to show the directory path on the screen.
0
 

Author Comment

by:acco_is
ID: 18069002
Well, I'm not sure that really answers the question.    I understand what the response.write does.   I'm just wanting to know what change I need to make in order for it to RUN the executable or batch file instead of under the IWAM account?   I know I got this to work fine a few years ago, but can't seem to reproduce it.  

Any other ideas?   Does it need to ran as a different user?  

Thanks
0
 
LVL 11

Expert Comment

by:walkerke
ID: 18069179
If you launch an application remotely by opening an ASP file on the server in your browser on your desktop, the application will be launched in the IWAM_servername user space. If that application does not require interaction, it will run and terminate. But if it does require interation, it will stay resident awaiting a response from the IWAM_servername user which will never come as there is no way to log in as IWAM_servername. So it will remain resident in the IWAM_servername user space until the server is restarted or the app is forced to quit using task manager.

Again, what is your objective? Are you expecting the app to load into your remote browser? I'm not familiary with any way to do that with ASP or any other web-based scripting. That type of function requires some sort of terminal interface into the server.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:acco_is
ID: 18069437
Well, we have an application that is entirely web based.   There is another software application that we will be passing data to.   I am creating a data file in XML and then need to call an executable or batch file that will process/write this data in to the other company's software.   Basically want a "click one button" to simplify things for the users.   If you follow me.

I've done it in an ASP page, calling a batch file to kick off an ftp call.  I just can't get the same to work here.  I have a few more ideas.    Any other thoughts?

Thanks
0
 
LVL 11

Accepted Solution

by:
walkerke earned 2000 total points
ID: 18069714
You may want to test your .bat file locally to see if it's generating a user prompt or an error. The "true" attribute in the WShShell.Run means the script will wait for the .bat file to complete before continuing. Errors will only be returned to the script once the .bat file terminates. If it's waiting for a user response, the script will remain in limbo until the response is received and the .bat file is finished. This particular command is designed more for locally executed VBScript than for remotely executed ASP.
0
 

Author Comment

by:acco_is
ID: 18069772
Ok, so that makes more sense why the return code for errors is 0.   Its isn't erroring at all, its actually working as intended, even if ran on my machine locally, not remotely.   It does the same thing, but just as IWAM.  

I think that's clears it up more.   I'll see if my other ideas work.

Thanks
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question