Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to execute a user application from vbscript?

    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!

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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.
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #3
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Daemonspyre View Post
    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

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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:


    Code:
    <%
    
    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.
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #5
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •