Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > My Script to run a Command-Line from ASP does not work.
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 25th January 15:55
lucas cowald
External User
 
Posts: 1
Default My Script to run a Command-Line from ASP does not work.



Hi,
My Script to run a Command-Line from ASP does not work. No errors are
returned either.
It is on IIS. The directory where the script exists is on Drive I:, The
executable .exe is on Drive D:
Do you see any problems with the script below? Can you help me modify it?

<%
Dim objWSS
Const cCMD = "clw45.exe -i k:\o\1.wmv -o k:\o\2.ghh -w 128 -df 0 -m
2 -p"
Set objWSS = CreateObject("WScript.Shell")
objWSS.CurrentDirectory = "D:\Program Files\Program\The Program\"
objWSS.Run "%COMSPEC% /c " & cCMD,,True
%>

Thank you very much for your help.
Lucas
  Reply With Quote


  sponsored links


2 25th January 15:55
michael harris \(mvp\)
External User
 
Posts: 1
Default My Script to run a Command-Line from ASP does not work.



There may be no runtime error thrown, but the program may still fail and end
with a non-zero exit code...

I don't recommend using CurrentDirectory in server side IIS/ASP. It changes
the current directory for the entire IIS *process*, not just your page.
Your page is running on just one of many threads under IIS...

So if in the few clock ticks between the time you set the current directory
and the time you call the Run method, another page that manipulates current
directory could change the current diretory to something else.

Personally, I would use a fully qualified, quoted path to the EXE and also
define the path and the arguments separately.

Dim exePath
exePath = """D:\Program Files\Program\The Program\clw45.exe"""

Dim args
args = " clw45.exe -i k:\o\1.wmv" _
& " -o k:\o\2.ghh -w 128 -df 0 -m 2 -p"

I'd also capture the exit code of what is run...

Dim exitCode
exitCode = objWSS.Run("%COMSPEC% /c " & exePath & args,0,True)
Response.Write "exitCode=" & exitCode

--
Michael Harris
Microsoft.MVP.Scripting

Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

TechNet Script Center Sample Scripts
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 do***entation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en
  Reply With Quote
3 25th January 15:55
lucas cowald
External User
 
Posts: 1
Default My Script to run a Command-Line from ASP does not work.


Hi Michael,

I tried your advice. I get exit code: 1
But the script still does not run the command. When I do it in the Command
window manually, it runs. Below is the latest that I tried:

<%
Dim objWSS, Path, cCMD, exitCode

Path = "D:\Program Files\Program\The Program\"
cCMD= "clw45.exe -i k:\o\1.wmv -o k:\o\2.ghh -w 128 -df 0 -m 2 -p"

Set objWSS = CreateObject("WScript.Shell")

objWSS.Run "%COMSPEC% /c " & Path & cCMD,,True

exitCode = objWSS.Run ("%COMSPEC% /c " & Path & cCMD,,True)

Response.Write exitCode
%>
  Reply With Quote


  sponsored links


4 25th January 15:55
michael harris \(mvp\)
External User
 
Posts: 1
Default My Script to run a Command-Line from ASP does not work.


When you tell the Run method to wait for the executed process to end (True
as the 3rd argument), then the return code from Run is the exitcode that
came from what was executed.

Either clw45.exe ran and exited with a 1 or the command shell itself (I
assume cmd.exe in this case) was unable to run the exe and exited with a 1.
I haven't seen any do***entation to support the latter case.

Does an exitcode of 1 from clw45.exe have a do***ented meaning?

In any case, logging on any running something from the command line is not
the same as trying to run the same thing from server side ASP code.

The biggest difference is the security context. The IUSR_machinename
account used for anonymous access doesn't have the same level of access as
the account you use to logon locally on a server.


--
Michael Harris
Microsoft.MVP.Scripting

Windows 2000 Scripting Guide
Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

TechNet Script Center Sample Scripts
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 do***entation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en
  Reply With Quote
5 6th February 10:24
lucas cowald
External User
 
Posts: 1
Default My Script to run a Command-Line from ASP does not work.


Hi,
My Script to run a Command-Line from ASP does not work. No errors are
returned either.
It is on IIS. The directory where the script exists is on Drive I:, The
executable .exe is on Drive D:
Do you see any problems with the script below? Can you help me modify it?

<%
Dim objWSS
Const cCMD = "clw45.exe -i k:\o\1.wmv -o k:\o\2.ghh -w 128 -df 0 -m
2 -p"
Set objWSS = CreateObject("WScript.Shell")
objWSS.CurrentDirectory = "D:\Program Files\Program\The Program\"
objWSS.Run "%COMSPEC% /c " & cCMD,,True
%>
  Reply With Quote
6 6th February 10:24
alvin bruney
External User
 
Posts: 1
Default My Script to run a Command-Line from ASP does not work.


Do you have the appropriate permissions? A web page cannot normally access
the disk unless special permission is granted. Typically only activeX
components can run in that regard

--


-----------
Got TidBits?
Get it here: http://www.networkip.net/tidbits
  Reply With Quote
7 11th February 07:03
lucas cowald
External User
 
Posts: 1
Default My Script to run a Command-Line from ASP does not work.


Hi,
My Script to run a Command-Line from ASP does not work. No errors are
returned either.
It is on IIS. The directory where the script exists is on Drive I:, The
executable .exe is on Drive D:
Do you see any problems with the script below? Can you help me modify it?

<%
Dim objWSS
Const cCMD = "clw45.exe -i k:\o\1.wmv -o k:\o\2.ghh -w 128 -df 0 -m
2 -p"
Set objWSS = CreateObject("WScript.Shell")
objWSS.CurrentDirectory = "D:\Program Files\Program\The Program\"
objWSS.Run "%COMSPEC% /c " & cCMD,,True
%>

Thank you very much for your help.
Lucas
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666