...

View Full Version : how to execute a user application from vbscript?



jambabe
06-29-2007, 09:51 AM
I'm trying to launch an application from vbscript. The application is supposed to read an XML file, parse the tags, and eventually generate an HTML file. I've tried the following piece of code (and many other vairations thereof), but the output file (the HTML file) isn't created:

<%
Option Explicit
%>

<html>
<head>
</head>
<body>

<%
Dim elem
Dim objShell

Response.Write("num elems: " & Request.Form.Count)
%>
<BR />

<%

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

For Each elem in Request.Form
Select Case elem
Case "HTMLFile"
Response.Write("got HTML")
objShell.Run("myapp.exe")
End Select
Next
Set objShell=Nothing
%>

The server is IIS 5.1. 'myapp' is the application I'm trying to launch, and a copy of which is in the IIS defalut web site directory (where the vbscript file is located).

Does anyone know what I'm doing wrong?

thanks!

Daemonspyre
06-29-2007, 02:35 PM
Does your anonymous user have read+execute access to your .EXE file (not the folder, the actual file)? You most likely have read, but not execute.

Also, you may need to run a Server.MapPath to the file, just so the server knows where to look.

I have no experience doing what you are doing, but those are the 2 big things that pop out.

jambabe
06-30-2007, 12:47 AM
Does your anonymous user have read+execute access to your .EXE file (not the folder, the actual file)? You most likely have read, but not execute.

Also, you may need to run a Server.MapPath to the file, just so the server knows where to look.

I have no experience doing what you are doing, but those are the 2 big things that pop out.

Thanks for your reply! I'd like to mention that I can launch this application from
the Windows Command Prompt window, and it does what I expect.

I've looked at the properties of the .EXE file in the IIS dialog box. Under the 'file'
tab, there are three properties: 'Script source access', 'Read', and 'Write', and they're all checked. For the parent folder, under the 'Directory' tab, 'Execute
Permissions:' text box says: 'Scripts and Executables'. So, please let me
know if you have something else in mind.

As for MapPath(), could you please give me an example of how that will be
used in this code snippet above?

thanks

Daemonspyre
06-30-2007, 02:28 AM
Here's the usage:

Server.MapPath("/path/to/file.exe")

Make sure that your AspEnableParentPaths is set to TRUE (or in IIS, Right Click your Site > PROPERTIES > Home Directory > Configuration > Options > Enable Parent Paths). It's turned off for security reasons, mainly because you don't want scripts to have access to your physical directory structure.

So in your case:




<%

Set objShell = Server.CreateObject("WScript.Shell")
'
Set File = Server.MapPath("/path/to/file.exe")

For Each elem in Request.Form
Select Case elem
Case "HTMLFile"
Response.Write("got HTML")
objShell.Run(file)
End Select
Next
Set objShell=Nothing
%>


The Server.MapPath() may not be necessary once the AspEnableParentPaths is set to TRUE.

jambabe
06-30-2007, 04:19 AM
I checked the 'Enable Parent Paths' option and it was set. Also, I included MapPath() in my code, but unfortunately, I didn't have much success. I'll keep playing with it a bit more, though. Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum