"Access is Denied" error when calling wshShell from ASP

M

Mark DuPrey

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
 
J

Jeff Cochran

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
 
M

Mark DuPrey

(e-mail address removed) (Jeff Cochran) wrote in message
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.

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
 
T

Tom B

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

Mark DuPrey

Tom B said:
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
 
B

Bob Barrows

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
 
M

Mark DuPrey

Bob Barrows said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top