Home > Return Code > Wscript Shell Exec Return Code

Wscript Shell Exec Return Code


If it had worked I wouldn't be posting here. Covered by US Patent. As for permissions. You’ll be auto redirected in 1 second. his comment is here

Because you will not post the real code there is no way to help you. The code I am running is doing the correct thing as evidenced by the lack of a JScript runtime error. Change the code and see what errors you get. ¯\_(ツ)_/¯ Monday, September 03, 2012 10:46 PM Reply | Quote 0 Sign in to vote Hi jrv, Yes the code I posted So to stop this nonsense, this is what I am really doing: cmd = new ActiveXObject("Wscript.Shell"); r = cmd.Run("WBAdmin ...", 0, true); So, any insight on the real problem?

Wscript Shell Exec Return Code

WshRunning ( = 0)The job is still running.WshFinished ( = 1)The job has completed.Legacy Code ExampleThe following code runs calc.exe and echoes the final status to the screen. Another way to get doublequotes inside a string is to "escape" them with double-doublequote marks like this: shellCommand="""C:\Program Files\SomeApp.exe""" 0 LVL 10 Overall: Level 10 VB Script 9 Scripting Languages Thus, -1 is 0xFFFFFFFF, and -2 is 0xFFFFFFFE.

Monday, September 03, 2012 11:42 PM Reply | Quote 0 Sign in to vote Hi, The docs for WshShell.Run specifically states: If [the bWaitOnReturn parameter to function is] set to true, Script returning an exit code [script.vbs] exitCode = InputBox ( "Enter Exit Code (0 - 255)", "Script", "0") If Not IsNumeric(exitCode) Then exitCode = 0 wscript.Quit(exitCode Mod 255) Script to handle LVL 7 Overall: Level 7 VB Script 5 Scripting Languages 2 Message Expert Comment by:CitizenRon ID: 329029972010-06-02 The problem with your attached VBScript, cusas76, is that in line 2 you set Wshshell.exec Status You can then test it using lines like: If iReturn <>0 Then MsgBox "Error: "& iReturn &" returned from "& strCommandLine Else MsgBox "Success - Return: 0

Strange, isn't it? #6 dm_4ever Total Posts : 3712 Scores: 93 Reward points : 0 Joined: 6/29/2006Location: Orange County, California Status: offline RE: Getting exit code with Exec method Wednesday, Vbscript Run Command Get Output So to stop this nonsense, this is what I am really doing: cmd = new ActiveXObject("Wscript.Shell"); r = cmd.Run("WBAdmin ...", 0, true); O.K., now, do you have any insight into the Next I tried exactly the same with a scripting run command and I got exactly the same results. Check This Out First I wanted to factor out scripting and find out what the error codes actually mean.

Not the answer you're looking for? Run Return Code 1 Can anyone point me in the right direction, whether it be how to make the "run" method more reliable or modifying the included code to catch the return of the called VBScript Copy Dim WshShell, oExec Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec("calc") Do While oExec.Status = 0 WScript.Sleep 100 Loop WScript.Echo oExec.Status JScript Copy var WshShell = new ActiveXObject("WScript.Shell"); var Browse other questions tagged vbscript or ask your own question.

Vbscript Run Command Get Output

Thanks for the help, Chris. I ran "WBAdmin get disk[s]" as both a limited user and an administrative user. Wscript Shell Exec Return Code The docs don't give any details of the status code from the "run" command; I've looked. Vbs Return Code The active window remains active. 9 Restore & Activate.

Join our community for more solutions or to ask questions. this content Monday, September 03, 2012 10:58 PM Reply | Quote 0 Sign in to vote The first step is to read the documentation: So we know that r is the return maybe? Is this in an HTA or and HTML page?. Exec Vs Run

Can you offer any insight to the stated question? Browse other questions tagged scripting vbscript wsh windows-scripting or ask your own question. It is impossible to get WBAdmin to return a -1 or -2. weblink Try to execute it. ¯\_(ツ)_/¯ Tuesday, September 04, 2012 3:29 AM Reply | Quote 0 Sign in to vote Hi jrv, Apparently you missed the earlier post that resolves your complaint:

Thanks for the help, Chris. Exec Stdout The issue I have with it is that I can't figure out how to catch the return code that the application throws. The jscript construct is syntactically and functionally incorrect.

Thanks for the help, Chris.

Edited by cjm51213 Tuesday, September 04, 2012 11:15 PM Tuesday, September 04, 2012 10:47 PM Reply | Quote Microsoft is conducting an online survey to understand your opinion of the Technet The first thing I would find out is if these exit codes are documented somewhere. If I were doing what you imply, I would be getting a JScript run time error "Wscript.Shell is null or is not an object." and not an unexplained return code from Error Codes Question has a verified solution.

In that case teh return code may not be what you expect. You cannot access teh shell withthat line of code. I have never seen or heard of an exception or error code that is higher than that. check over here See the Microsft documetation on system and application error generation in the SDK. -1 and -2 are not Windows system error codes ever. ¯\_(ツ)_/¯ Edited by jrv Tuesday, September 04, 2012

Always remember Search is your friend. #3 buffalokml Total Posts : 15 Scores: 0 Reward points : 0 Joined: 4/3/2006 Status: offline RE: return value for run method Monday, August To return r as an unsigned hex string value, you can use a function like this: function hex(n) { return n < 0 ? (n + Math.pow(2, 32)).toString(0x10) : n.toString(0x10); } WScript.Echo " " WScript.Echo "Running command: " & strCommand strReturn = objShell.Run("cmd /c " & strCommand, 0, true) if strReturn <> 0 then WScript.Echo "Error occured.... " else WScript.Echo "************* Finished Is it a WSF file?

Therefore if my answer works for you, please distribute some points to TakedaT too. How does Decommission (and Revolt) work with multiple permanents leaving the battlefield?