Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Running a batch from ASP

Posted on 2006-12-01
6
Medium Priority
?
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

688 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