Befor doing it we need to check whether Windows Script Host is installed and also check whether it is enabled. If every thing is proper then we can say the object is ready for use ...
------------------------------------------------
<%
set Wshell = Server. CreateObject ( "WScript.Shell")
Wshell.run "c:\mytests\test1.exe"
set wshell = nothing
%> set wshell = CreateObject("WScript.Shell")
wshell.run "c:\testfile.exe"
set wshell = nothing
------------------------------------------------------
Be sure you need to use the local path of the file to be executed and also check for the permissions.
To retrieve the Output from Command
Lets take an example of Ping Command from an IP adress..
-------------------code------------
Response.Buffer = true
Set objWShell = CreateObject("WScript.Shell")
Set objCmd = objWShell.Exec("ping " & url)
strPResult = objCmd.StdOut.Readall()
Set objCmd = nothing:
Set objWShell = nothing
strStatus = "offline"
if InStr(strPResult,"TTL=")>0 then
strStatus = "online"
response.write url & " is " & strStatus
response.write ".
" & replace(strPResult,vbCrLf,"
")
" & replace(strPResult,vbCrLf,"
")
-------------------------
*************************************************************************
Great to see this...
ReplyDeleteKeep posting the blogs of this type.
Bye