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 7 of 7
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    24
    Thanks
    3
    Thanked 0 Times in 0 Posts

    objWShell.Exec with Relative Paths

    I am calling an .exe from my asp page and need to do so using relative paths. I am having problem as no errors are being output and the exe is not being called.

    Code:
    <% 
        DIM strArea
        strArea = Request.QueryString("area")
        DIM strPathFTP
        strPathFTP = "\\SERVERNAME\temp" & strArea
    
        DIM objFSO
        set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    
        Set objWShell = CreateObject("WScript.Shell")
        Set objWScript = objWShell.Exec("unzip """ & strPathFTP & "\" & strArea & "file.zip"" -d """ & strPathFTP & """")
    %>
    I tried to also use things like "\", "\\", "..\" and dump into root directory and still same issues. Is there a limitation I am not aware of or did I make a typo somewhere I'm just not seeing? If I specify the full with drive letter it works as expected so its not a rights issue.

    Code:
    <% 
        DIM strArea
        strArea = Request.QueryString("area")
        DIM strPathFTP
        strPathFTP = "C:\temp\" & strArea
    
    
        DIM objFSO
        set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    
        Set objWShell = CreateObject("WScript.Shell")
        Set objWScript = objWShell.Exec("unzip C:\temp\file.zip -d C:\temp")
    %>

  • #2
    New Coder
    Join Date
    Mar 2011
    Posts
    24
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I found a workaround but hopefully someone has a suggestion that would prevent me having to do this... If I setup a site on the local machine I can run the .exe that I need and then call objFSO.MoveFolder to move it to a different server via relative path. I would prefer to not have a local site on this machine though if I dont have to but no sure if there is a way around that or not.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,014
    Thanks
    79
    Thanked 4,436 Times in 4,401 Posts
    Code:
    strPathFTP = "\\SERVERNAME\temp" & strArea
    ...
    Set objWScript = objWShell.Exec("unzip """ & strPathFTP & "\" & strArea & "file.zip"" -d """ & strPathFTP & """")
    Maybe some good old fashioned debugging is called for??

    I would *NOT* have tried to do everything inline like that. Makes it nearly impossible to debug.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,014
    Thanks
    79
    Thanked 4,436 Times in 4,401 Posts
    If it's not obvious, the above means that if, for example strArea contains "widget", then you will be doing
    Code:
    unzip "\\SERVERNAME\tempwidgetwidgetfile.zip ..."
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    Mar 2011
    Posts
    24
    Thanks
    3
    Thanked 0 Times in 0 Posts
    actually no thats not true as I have a slash in there (and I realized when I pasted I missed a \ that is actually present in my code) so it would be:

    Code:
    unzip "\\SERVERNAME\temp\widget\widgetfile.zip
    The code SHOULD have said
    Code:
    <% 
        DIM strArea
        strArea = Request.QueryString("area")
        DIM strPathFTP
        strPathFTP = "\\SERVERNAME\temp\" & strArea
    
        DIM objFSO
        set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    
        Set objWShell = CreateObject("WScript.Shell")
        Set objWScript = objWShell.Exec("unzip """ & strPathFTP & "\" & strArea & "file.zip"" -d """ & strPathFTP & """")
    %>
    Again using local machine I'm good, if I specify a remote server thats where the issues come in. The solution may be for me to create a local dir on the fly, unzip files and move to a remote server but not yet sure.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,014
    Thanks
    79
    Thanked 4,436 Times in 4,401 Posts
    Looking back at your first post: You say if you use the full path it works. But then you demonstrate that with C:\xxxxx

    Given that your other path is of the form \\SERVERNAME, how can you say "the full path works"??

    Are you saying the C: and \\SERVERNAME are the same drive??

    If not, then I don't see how using C: has domonstrated anything at all about "rights" to \\SERVENAME.

    You do know that your ASP code (and I *think* that includes the code you invoke via Wscript.Shell) is running with the permissions of "IUSR_xxx" where "xxx" is the name of the web server machine? So are you sure the the "IUSR_xxx" user has permissions to \\SERVERNAME??

    I have to admit that given you say you can use MoveFolder to make it work it sounds like permissions are not an issue, but... Just trying to be sure.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,014
    Thanks
    79
    Thanked 4,436 Times in 4,401 Posts
    Have you tried having the unzip code dump all its output, including error output, into a log file? So if there are errors you can see them happening? That is use "unzip xxxx > logout.txt 2> logerr.txt"?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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