Try running the modified script. You’ll be auto redirected in 1 second. I've originally tried the code you suggested even before I entered this forum. We're currently using objStdOut.ReadAll to retrieve all of ipconfigs output and store it in the strOutput variable. http://smartnewsolutions.com/return-code/return-code-242-sap.html
list of files based on permission Does every data type just boil down to nodes with pointers? The radix of the status code is not very important if I don't have any explanations of any status codes. You could fix it: Change shellCommand on line 2 to "SomeApp.exe" Add another variable shellCommandPath, right after line 2 and set that to "C:\" Change line 5 to oShell.run "%comspec% /c 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
Thanks for the help, Chris. The second paragraph points out the inconsistency of a -2 return from the "run" command and the same command running from a command prompt and running successfully and raises the question 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, share|improve this answer answered Apr 21 '14 at 3:20 JunzCode 12 1 OP was asking how to cause a VBScript to produce a nonzero exit code.
Did you even try them? strComputer="." shellCommand="C:\someapp.exe" Set oShell=CreateObject("Wscript.Shell") iReturn=oShell.run(shellCommand,1,True) wscript.echo iReturn WScript.Sleep 2000 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Wscript.shell Run Return Code 1 After you actually posted your code, I gave 2 more suggestions that have yet to get a response from you. Thanks for the help, Chris. http://www.visualbasicscript.com/return-value-for-run-method-m37325.aspx Your original code had %comspec% /c in Go to Solution 6 4 2 +1 4 Participants TakedaT(6 comments) LVL 10 VB Script9 Scripting Languages3 cusas76(4 comments) CitizenRon(2 comments) LVL 7 VB
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 Vbscript Return Code The code you have just attached is redundant. You'll find this interesting. The application's console output? –Helen May 20 '11 at 5:49 add a comment| 1 Answer 1 active oldest votes up vote 11 down vote accepted You will want to use the
asked 3 years ago viewed 1379 times active 2 years ago Related 2Team City MSTest runner exits with not zero code - Symantec1Return code of scheduled task prefixed with 0x8007000 in Copy Set objShell = CreateObject("WScript.Shell") objShell.Exec "%COMSPEC% /k ipconfig > ipconfig_output.txt" After running the script above, look at the contents of the ipconfig_output.txt file. Wshshell Run Vs Exec In any case, as you noted, this is not a scripting issue. Vbscript Run Command Get Output Null check OR isEmpty Check Kids shuffling cards Is it bad practice to use GET method as login username/password for administrators?
All Forums >> [Scripting] >> WSH & Client Side VBScript Forum MenuLog inRegistration / Sign up RSS FeedThread Options View Printable PageThread Reading Mode return value for run method Author http://smartnewsolutions.com/return-code/scp-return-code-1.html Why? So, perhaps the script Creates something, called an object, and then Runs something. In any case this is not a scripting question. Shell.run Error Codes
We're just about to leap into some of that complexity, so stay with us and stay focused during the next section. In any case, as you noted, this is not a scripting issue. Thus, -1 is 0xFFFFFFFF, and -2 is 0xFFFFFFFE. Source asked 5 years ago viewed 30097 times active 3 years ago Linked 2 JScript: how to run external command and get output? 1 VBScript - Capturing output from stdout 0 VBA
Then navigate to the C:\Scripts directory and run the script by typing cscript RunIPConfig.vbs and then pressing ENTER. Almost all programs return positive result codes or negative values that map to hex values between 0x80000001 ox8007FFFF. Is there a reason why similar or the same musical instruments would develop? Vbscript Return Value We'll examine each line and if it includes the string "Physical Address", we'll display it; otherwise, the line will not be displayed.
We want the error code from Ping, not from Cmd.exe (or Command.exe), so we run Ping directly. If it isn't a valid program, the command-interpreter will let you know by displaying an error message. The Exec method can return a WshScriptExec object. have a peek here Monday, September 03, 2012 10:58 PM Reply | Quote 0 Sign in to vote The first step is to read the documentation: http://msdn.microsoft.com/en-us/library/d5fk67ky.aspx So we know that r is the return
For example, if you have a batch script called Checkserver.bat in the C:\Batchscripts directory, then the string you pass to Run would look like: %COMSPEC% /k C:\batchscripts\checkserver.bat. Without more complete information the question cannot be answered. ¯\_(ツ)_/¯ Tuesday, September 04, 2012 1:21 AM Reply | Quote 0 Sign in to vote It is a Microsoft utilitiy and it However, if I get a -2 but then I run the command from a command prompt, it works, which leads me to believe that I am fighting an environmental problem.