troubleshooting Question

Questions about ASPExec

Avatar of fastrucking
fastrucking asked on
8 Comments1 Solution2909 ViewsLast Modified:
Here is my scenario.  I have a webserver sitting in my office in San Diego.  My copier that is in LA pushes imaged documents (PDF's) down to the hard disk of my server in San Diego.  Somtimes the copier has a hickup or the VPN drops and the file gets created with a zero file size and it shows that it is opened in read only mode.  My application sees the file and trys to delete it but gets an error that the file is in use.  However, the file isn't really in use it's just stuck in an incosisten state which makes it impossible to delete.

In order to delete the file I have to use the computer managment tool connect to my server open shared folders and then go to open files locate the file and choose close file.  Now I can delete the file manually or by using my application (ASP web application).

However I found a way to do this from the command line but it has to be executed on the server.  Here is the command.

for /f "skip=4 tokens=1" %%a in ('net files') do net files %%a /close

When I run this command from the command line or a .bat file the open files are closed and I can then delete the file.

However I want to run this from an ASP page.  So here is what I have tried so far.
'Set WShShell = Server.CreateObject("WScript.Shell")
'RetCode = WShShell.Run("C:\DISR\web_files\bat_files\openfiles.bat",1 , True)

'if RetCode = 0 Then

'response.write "All open file locks have been removed."

'response.write RetCode
'response.write "Nothing Happened"
'Response.Redirect "Errors.htm"

This didn't seem to work so then I tried the ASPExec with the following code.
'Set Executor = Server.CreateObject("ASPExec.Execute")
 ' Executor.Application = "CMD.exe"
  'Executor.Parameters = "/C C:\DISR\web_files\bat_files\openfiles.bat"
  'Executor.ShowWindow = False
  'strResult = (Executor.ExecuteDosApp)
  'Response.Write "<pre>" & strResult & "</pre>"
This didn't work either and just displayed a blank page.

So I finally tired this next piece of code which gave me some clue as to what is going on.
Set obj_AspExec = Server.CreateObject("ASPExec.Execute")
obj_AspExec.Application = "cmd"
obj_AspExec.Parameters = "/c net files"
str_Result = obj_AspExec.ExecuteDosApp
Response.Write "<pre>" & str_Result & "</pre>"

----When this is run I get the following error.  I decided to cut the command down just a litte and see if I could break it down into smaller peices to troubleshoot.
System error 5 has occurred.

Access is denied.

However when I use the obj_AspExec.Parameters = "/c net files" with say obj_AspExec.Parameters = "/c net time" or some other net command it displays the following.
Current time at \\FSTSERVER01 is 8/23/2005 12:10 PM

The command completed successfully.

I'm not sure why I get access denied when I try and use net files.  WHen I execute that from the command line it works and it shows me all the open files but using ASPExec I get access denied.

I have been pulling my hair out on this problem for a day now so if someone has a solution or even a better idea PLEASE HELP!

In your solution please provide working examples with working code or linked references to examples.

THank you in advance.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros