Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call external program, call winrar

Status
Not open for further replies.

MrDontKnowNothing

Programmer
Jun 26, 2003
94
DE
greetings,

does anyone know, how to call a external program from my asp-website? in particular, i need zip a file using winrar.

any hints appreciated!

thanks

alex
 
we use this script to call programs when users login to the network its called with the logon batch file using:

cscript exec.vbs username password <program>

Hope this helps


'USAGE: cscript|wscript VBRUNAS.VBS Username Password Command
'DESC: A RUNAS replacement to take password at a command prompt.
'NOTES: This is meant to be used for local access. If you want to run a command
'across the network as another user, you must add the /NETONLY switch to the RUNAS
'command.

On Error Resume Next
dim WshShell,oArgs,FSO

set oArgs=wscript.Arguments

if InStr(oArgs(0),&quot;?&quot;)<>0 then
wscript.echo VBCRLF & &quot;? HELP ?&quot; & VBCRLF
Usage
end if

if oArgs.Count <3 then
wscript.echo VBCRLF & &quot;! Usage Error !&quot; & VBCRLF
Usage
end if

sUser=oArgs(0)
sPass=oArgs(1)&VBCRLF
sCmd=oArgs(2)

set WshShell = CreateObject(&quot;WScript.Shell&quot;)
set WshEnv = WshShell.Environment(&quot;Process&quot;)
WinPath = WshEnv(&quot;SystemRoot&quot;)&&quot;\System32\runas.exe&quot;
set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)

if FSO.FileExists(winpath) then
'wscript.echo winpath & &quot; &quot; & &quot;verified&quot;
else
wscript.echo &quot;!! ERROR !!&quot; & VBCRLF & &quot;Can't find or verify &quot; & winpath &&quot;.&quot; & VBCRLF & &quot;You must be running Windows 2000 for this script to work.&quot;
set WshShell=Nothing
set WshEnv=Nothing
set oArgs=Nothing
set FSO=Nothing
wscript.quit
end if

rc=WshShell.Run(&quot;runas /user:&quot; & sUser & &quot; &quot; & CHR(34) & sCmd & CHR(34), 2, FALSE)
Wscript.Sleep 30 'need to give time for window to open.
WshShell.AppActivate(WinPath) 'make sure we grab the right window to send password to
WshShell.SendKeys sPass 'send the password to the waiting window.

set WshShell=Nothing
set oArgs=Nothing
set WshEnv=Nothing
set FSO=Nothing

wscript.quit

'************************
'* Usage Subroutine *
'************************
Sub Usage()
On Error Resume Next
msg=&quot;Usage: cscript|wscript vbrunas.vbs Username Password Command&quot; & VBCRLF & VBCRLF & &quot;You should use the full path where necessary and put long file names or commands&quot; & VBCRLF & &quot;with parameters in quotes&quot; & VBCRLF & VBCRLF &&quot;For example:&quot; & VBCRLF &&quot; cscript vbrunas.vbs quilogy\jhicks luckydog e:\scripts\admin.vbs&quot; & VBCRLF & VBCRLF &&quot; cscript vbrunas.vbs quilogy\jhicks luckydog &quot; & CHR(34) &&quot;e:\program files\scripts\admin.vbs 1stParameter 2ndParameter&quot; & CHR(34)& VBCRLF & VBCRLF & VBCLRF & &quot;cscript vbrunas.vbs /?|-? will display this message.&quot;

wscript.echo msg

wscript.quit

end sub
'End of Script
 
That is all fine and dandy but it won't work from asp... as the wscript object is not available because the wscript or cscript engine is not running the vbscript... If you find a way to do this I would love to know... As far as I know there is no way to invoke a command from an asp program... at least in vbscript... You may be able to do so by using a com object?
 
Have you tried something like this:
Code:
Set WshShell=Server.CreateObject(&quot;WScript.Shell&quot;)

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top