"Access is Denied" error when calling wshShell from ASP

Discussion in 'ASP General' started by Mark DuPrey, Sep 17, 2003.

  1. Mark DuPrey

    Mark DuPrey Guest

    I've got a script in an ASP page that is supposed to extract certain
    files from a zip file, move them, create a new zip with the moved
    files and then make a self-extracting archive out of the new zip file.
    I'm doing this using wshShell.Exec, the WinZip command line tool and
    zip2exe.exe from the pkware suite (because WinZip's command line
    doesn't support creating self-extracting archives and for historical
    compatibility reasons). This is running on Windows 2000 Server and IIS
    5.0 both fully patched as of yesterday. The relevant code is below:

    set objFSO = CreateObject("Scripting.FileSystemObject")

    intProject = 12345
    strZipFile = "F:\path\" & intProject & ".zip"

    If objFSO.FileExists (strZipFile) Then

    ' extracts .doc and .txt files from zip file - works fine
    Set objShell = CreateObject("WScript.Shell")
    Set objCmd = objShell.Exec("c:\Program Files\Winzip\wzunzip.exe -O-
    " & strZipFile & " *.doc *.txt f:\working\doc\")
    set objCmd = Nothing
    Set objShell = Nothing

    ' makes new zip file in a different directory from extracted .doc
    and .txt files - works fine
    Set objShell = CreateObject("WScript.Shell")
    Set objCmd = objShell.Exec("c:\Program Files\Winzip\wzzip -ybc
    f:\working\temp\" & intProject & ".zip f:\working\doc\*" & intProject
    & ".doc f:\working\doc\*" & intProject & ".txt")
    set objCmd = Nothing
    Set objShell = Nothing

    ' makes self-extracting .exe in a different directory from new zip
    file - fails every time
    Set objShell = CreateObject("WScript.Shell")
    Set objCmd = Shell.Exec("c:\Program Files\pkware\Zip2Exe
    f:\working\temp\" & intProject & ".zip f:\working\exe\")
    set objCmd = Nothing
    Set objShell = Nothing
    End If
    set objFSO = Nothing

    Executing the WinZip command-line programs from the page works fine.
    Every time I try to execute Zip2Exe I get:

    WshShell.Exec error '80070005'

    Access is denied.

    /myfile.asp, line ###

    I've changed the permissions on Zip2Exe to match the permissions on
    the WinZip tools wzzip and wzunzip to no avail. I've tried writing a
    batch file that is called by wshShell.Exec and having that call
    Zip2Exe with no luck. The Zip2Exe command does work if executed
    manually on the command line so I know the program and the command
    both work. It's obviously a permissions problem but I'm stumped as
    where to look next. Any suggestions will be greatly appreciated.

    Mark DuPrey
     
    Mark DuPrey, Sep 17, 2003
    #1
    1. Advertising

  2. Mark DuPrey

    Jeff Cochran Guest

    On 17 Sep 2003 07:55:19 -0700, (Mark DuPrey)
    wrote:

    >I've got a script in an ASP page that is supposed to extract certain
    >files from a zip file, move them, create a new zip with the moved
    >files and then make a self-extracting archive out of the new zip file.
    >I'm doing this using wshShell.Exec, the WinZip command line tool and
    >zip2exe.exe from the pkware suite (because WinZip's command line
    >doesn't support creating self-extracting archives and for historical
    >compatibility reasons). This is running on Windows 2000 Server and IIS
    >5.0 both fully patched as of yesterday. The relevant code is below:
    >
    >set objFSO = CreateObject("Scripting.FileSystemObject")
    >
    >intProject = 12345
    >strZipFile = "F:\path\" & intProject & ".zip"
    >
    >If objFSO.FileExists (strZipFile) Then
    >
    > ' extracts .doc and .txt files from zip file - works fine
    > Set objShell = CreateObject("WScript.Shell")
    > Set objCmd = objShell.Exec("c:\Program Files\Winzip\wzunzip.exe -O-
    >" & strZipFile & " *.doc *.txt f:\working\doc\")
    > set objCmd = Nothing
    > Set objShell = Nothing
    >
    > ' makes new zip file in a different directory from extracted .doc
    >and .txt files - works fine
    > Set objShell = CreateObject("WScript.Shell")
    > Set objCmd = objShell.Exec("c:\Program Files\Winzip\wzzip -ybc
    >f:\working\temp\" & intProject & ".zip f:\working\doc\*" & intProject
    >& ".doc f:\working\doc\*" & intProject & ".txt")
    > set objCmd = Nothing
    > Set objShell = Nothing
    >
    > ' makes self-extracting .exe in a different directory from new zip
    >file - fails every time
    > Set objShell = CreateObject("WScript.Shell")
    > Set objCmd = Shell.Exec("c:\Program Files\pkware\Zip2Exe
    >f:\working\temp\" & intProject & ".zip f:\working\exe\")
    > set objCmd = Nothing
    > Set objShell = Nothing
    >End If
    >set objFSO = Nothing
    >
    >Executing the WinZip command-line programs from the page works fine.
    >Every time I try to execute Zip2Exe I get:
    >
    >WshShell.Exec error '80070005'
    >
    >Access is denied.
    >
    >/myfile.asp, line ###


    It would help if you told us the line number, and showed the snippet
    arond it.

    >I've changed the permissions on Zip2Exe to match the permissions on
    >the WinZip tools wzzip and wzunzip to no avail. I've tried writing a
    >batch file that is called by wshShell.Exec and having that call
    >Zip2Exe with no luck. The Zip2Exe command does work if executed
    >manually on the command line so I know the program and the command
    >both work. It's obviously a permissions problem but I'm stumped as
    >where to look next. Any suggestions will be greatly appreciated.


    Keep in mind that the command line may work because you're logged in
    with a user account that has permission, while the ASP may not because
    the user you're running under doesn't. And it's not just the EXE
    file, but the input and output files and folders that need appropriate
    permissions.

    Jeff
     
    Jeff Cochran, Sep 17, 2003
    #2
    1. Advertising

  3. Mark DuPrey

    Mark DuPrey Guest

    (Jeff Cochran) wrote in message
    <snip>
    > It would help if you told us the line number, and showed the snippet
    > arond it.


    The code is in the original message and it's even commented where it
    doesn't work. I can't post the actual code without violating a
    confidentiality agreement. The only thing that was changed was I
    stripped out some code that returned STDOUT from the WinZip command
    line and changed the type of files extracted from the .zip.

    <snip>
    > Keep in mind that the command line may work because you're logged in
    > with a user account that has permission, while the ASP may not because
    > the user you're running under doesn't. And it's not just the EXE
    > file, but the input and output files and folders that need appropriate
    > permissions.


    I'm aware of the permissions being different for different users. As I
    mentioned I have tried to alleviate this and make sure that the
    permissions on the executable match. Thanks for the suggestion about
    the input/output folders. I'll check that.

    Mark DuPrey
     
    Mark DuPrey, Sep 18, 2003
    #3
  4. Mark DuPrey

    Tom B Guest

    Your ASP page runs under the IUSR_machinename account, did you give that
    SPECIFIC user permission?

    "Mark DuPrey" <> wrote in message
    news:...
    > I've got a script in an ASP page that is supposed to extract certain
    > files from a zip file, move them, create a new zip with the moved
    > files and then make a self-extracting archive out of the new zip file.
    > I'm doing this using wshShell.Exec, the WinZip command line tool and
    > zip2exe.exe from the pkware suite (because WinZip's command line
    > doesn't support creating self-extracting archives and for historical
    > compatibility reasons). This is running on Windows 2000 Server and IIS
    > 5.0 both fully patched as of yesterday. The relevant code is below:
    >
    > set objFSO = CreateObject("Scripting.FileSystemObject")
    >
    > intProject = 12345
    > strZipFile = "F:\path\" & intProject & ".zip"
    >
    > If objFSO.FileExists (strZipFile) Then
    >
    > ' extracts .doc and .txt files from zip file - works fine
    > Set objShell = CreateObject("WScript.Shell")
    > Set objCmd = objShell.Exec("c:\Program Files\Winzip\wzunzip.exe -O-
    > " & strZipFile & " *.doc *.txt f:\working\doc\")
    > set objCmd = Nothing
    > Set objShell = Nothing
    >
    > ' makes new zip file in a different directory from extracted .doc
    > and .txt files - works fine
    > Set objShell = CreateObject("WScript.Shell")
    > Set objCmd = objShell.Exec("c:\Program Files\Winzip\wzzip -ybc
    > f:\working\temp\" & intProject & ".zip f:\working\doc\*" & intProject
    > & ".doc f:\working\doc\*" & intProject & ".txt")
    > set objCmd = Nothing
    > Set objShell = Nothing
    >
    > ' makes self-extracting .exe in a different directory from new zip
    > file - fails every time
    > Set objShell = CreateObject("WScript.Shell")
    > Set objCmd = Shell.Exec("c:\Program Files\pkware\Zip2Exe
    > f:\working\temp\" & intProject & ".zip f:\working\exe\")
    > set objCmd = Nothing
    > Set objShell = Nothing
    > End If
    > set objFSO = Nothing
    >
    > Executing the WinZip command-line programs from the page works fine.
    > Every time I try to execute Zip2Exe I get:
    >
    > WshShell.Exec error '80070005'
    >
    > Access is denied.
    >
    > /myfile.asp, line ###
    >
    > I've changed the permissions on Zip2Exe to match the permissions on
    > the WinZip tools wzzip and wzunzip to no avail. I've tried writing a
    > batch file that is called by wshShell.Exec and having that call
    > Zip2Exe with no luck. The Zip2Exe command does work if executed
    > manually on the command line so I know the program and the command
    > both work. It's obviously a permissions problem but I'm stumped as
    > where to look next. Any suggestions will be greatly appreciated.
    >
    > Mark DuPrey
     
    Tom B, Sep 19, 2003
    #4
  5. Mark DuPrey

    Mark DuPrey Guest

    "Tom B" <> wrote in message news:<>...
    > Your ASP page runs under the IUSR_machinename account, did you give that
    > SPECIFIC user permission?
    >


    Yes. Both ISUR_machinename and IWAM_machinename both have full
    permissions to the executable and the directories it accesses.

    Mark DuPrey
     
    Mark DuPrey, Sep 22, 2003
    #5
  6. Mark DuPrey

    Bob Barrows Guest

    Is f: a local drive? or a map to a drive on another machine? If the latter,
    then IUSR_ probably does not have the rights it needs. To access files on
    another box, you need a domain user account. IUSR is a local account.

    Hmm, that makes me wonder how the previous lines can be working with no
    error ...

    Bob Barrows

    Mark DuPrey wrote:
    > I've got a script in an ASP page that is supposed to extract certain
    > files from a zip file, move them, create a new zip with the moved
    > files and then make a self-extracting archive out of the new zip file.
    > I'm doing this using wshShell.Exec, the WinZip command line tool and
    > zip2exe.exe from the pkware suite (because WinZip's command line
    > doesn't support creating self-extracting archives and for historical
    > compatibility reasons). This is running on Windows 2000 Server and IIS
    > 5.0 both fully patched as of yesterday. The relevant code is below:
    >
    > set objFSO = CreateObject("Scripting.FileSystemObject")
    >
    > intProject = 12345
    > strZipFile = "F:\path\" & intProject & ".zip"
    >
    > If objFSO.FileExists (strZipFile) Then
    >
    > ' extracts .doc and .txt files from zip file - works fine
    > Set objShell = CreateObject("WScript.Shell")
    > Set objCmd = objShell.Exec("c:\Program Files\Winzip\wzunzip.exe -O-
    > " & strZipFile & " *.doc *.txt f:\working\doc\")
    > set objCmd = Nothing
    > Set objShell = Nothing
    >
    > ' makes new zip file in a different directory from extracted .doc
    > and .txt files - works fine
    > Set objShell = CreateObject("WScript.Shell")
    > Set objCmd = objShell.Exec("c:\Program Files\Winzip\wzzip -ybc
    > f:\working\temp\" & intProject & ".zip f:\working\doc\*" & intProject
    > & ".doc f:\working\doc\*" & intProject & ".txt")
    > set objCmd = Nothing
    > Set objShell = Nothing
    >
    > ' makes self-extracting .exe in a different directory from new zip
    > file - fails every time
    > Set objShell = CreateObject("WScript.Shell")
    > Set objCmd = Shell.Exec("c:\Program Files\pkware\Zip2Exe
    > f:\working\temp\" & intProject & ".zip f:\working\exe\")
    > set objCmd = Nothing
    > Set objShell = Nothing
    > End If
    > set objFSO = Nothing
    >
    > Executing the WinZip command-line programs from the page works fine.
    > Every time I try to execute Zip2Exe I get:
    >
    > WshShell.Exec error '80070005'
    >
    > Access is denied.
    >
    > /myfile.asp, line ###
    >
    > I've changed the permissions on Zip2Exe to match the permissions on
    > the WinZip tools wzzip and wzunzip to no avail. I've tried writing a
    > batch file that is called by wshShell.Exec and having that call
    > Zip2Exe with no luck. The Zip2Exe command does work if executed
    > manually on the command line so I know the program and the command
    > both work. It's obviously a permissions problem but I'm stumped as
    > where to look next. Any suggestions will be greatly appreciated.
    >
    > Mark DuPrey
     
    Bob Barrows, Sep 22, 2003
    #6
  7. Mark DuPrey

    Mark DuPrey Guest

    "Bob Barrows" <> wrote in message news:<>...
    > Is f: a local drive? or a map to a drive on another machine? If the latter,
    > then IUSR_ probably does not have the rights it needs. To access files on
    > another box, you need a domain user account. IUSR is a local account.
    >
    > Hmm, that makes me wonder how the previous lines can be working with no
    > error ...
    >
    > Bob Barrows


    f: is a local drive and as I mentioned the IUSR and IWAM accounts both
    have full permissions on the executable and the directories it
    accesses

    Even though I haven't made any progress, thanks to all who have
    offered suggestions so far.

    Mark DuPrey
     
    Mark DuPrey, Sep 22, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stan
    Replies:
    9
    Views:
    3,061
    Steven Cheng[MSFT]
    Oct 1, 2004
  2. Paul Bergson

    wshshell.run

    Paul Bergson, Feb 7, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    7,003
    ptlattamen
    Jan 31, 2008
  3. JPC
    Replies:
    1
    Views:
    144
  4. David Morgan

    WshShell.Run & ASP - Return code is always 1

    David Morgan, Aug 13, 2007, in forum: ASP General
    Replies:
    3
    Views:
    287
    Bookham Measures
    Aug 21, 2007
  5. JB
    Replies:
    1
    Views:
    105
    Bob Barrows [MVP]
    Aug 29, 2008
Loading...

Share This Page