Link to home
Start Free TrialLog in
Avatar of acco_is
acco_is

asked on

Running a batch from ASP

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
Avatar of walkerke
walkerke

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.
Avatar of acco_is

ASKER

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
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.
Avatar of acco_is

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of walkerke
walkerke

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of acco_is

ASKER

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