Home > Return Code > Wshshell Run Get Return Code

Wshshell Run Get Return Code

Contents

If the Return code is generated "before" the application ends (I don't really know how it could, unless there's some weird recursive application launching going on) then that's all you get. Edited by cjm51213 Tuesday, September 04, 2012 3:42 AM Tuesday, September 04, 2012 3:39 AM Reply | Quote 0 Sign in to vote So you were making up code that we I'm a doctor. The documentation says: "If set to true, script execution halts until the program finishes, and Run returns any error code returned by the program. his comment is here

Not the answer you're looking for? Connect with top rated Experts 10 Experts available now in Live! If bWaitOnReturn is not specified or FALSE, this method immediately returns to script execution rather than waiting on the process termination (and returns an error code of 0) Specifying the bWaitOnReturn Results 1 to 2 of 2 Thread: [RESOLVED] Return Code from oshell.run Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to https://social.technet.microsoft.com/Forums/scriptcenter/en-US/4a92021f-0378-46f9-932e-a25f4e18ad55/meaning-of-return-codes-from-wscriptshellrun?forum=ITCG

Vbscript Run Return Code

Doing all of this via API calls just isn't worth it when you've got such a handy object to use.: : : : : : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]: : : : : : Assuming I am right, and I want to run this script from the Task Scheduler, what am I going to have to do? How was I supposed to know that my mods to your code didnt work. Tuesday, September 04, 2012 10:10 PM Reply | Quote 0 Sign in to vote I ran wbadmin get status in an elevated command window and I get a -2 exit code

Microsoft reserves all rights associated with the materials on this site. The interpretation of that error code depends entirely on that program. Edited by cjm51213 Monday, September 03, 2012 9:55 PM Monday, September 03, 2012 9:55 PM Reply | Quote Answers 0 Sign in to vote I ran wbadmin get status in an Shell.run Error Codes The code I am running is doing the correct thing as evidenced by the lack of a JScript runtime error.

If bWaitOnReturn is set to TRUE, the Run method returns any error code returned by the application. Wshshell Run Vs Exec What is this blue thing in a photograph of a bright light? Not all programs make use of this. http://stackoverflow.com/questions/6060876/vbscript-getting-results-from-shell Question has a verified solution.

iReturn should then be your exit code. Set objShell = CreateObject("WScript.Shell") iReturn=objShell.Run("yourcommmandhere",0,True) wscript.echo iReturn Select all Open in new window 0 LVL 10 Overall: Level 10 VB Script Wscript.shell Exec Stdout p/s: my batch file use to decrypt file with .GPG extension Thanks & Best Regards, Last modified Nov 11, 2009 at4:52AM SvenGroot Dim errorLevel errorLevel = shell.Run("AG_Decrypt_Backup.bat", 1, True) Don't Is it correct name Windows Script Host Object Model or it's listed under some other name?: I have the exact setup as you and found it by that name.It's c:winntsystems32wshocm.ocx 0 Doing all of this via API calls just isn't worth it when you've got such a handy object to use.[size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size] 0 · Share on Facebook infidel Member Posts: 2,900 January 2003

  1. Nearly every TV website, magazine or online news has one on their site, and even some e-commerce sites have one.
  2. Bill Marked as answer by IamMredMicrosoft employee, Owner Thursday, September 20, 2012 10:27 PM Tuesday, September 04, 2012 10:16 PM Reply | Quote Moderator All replies 0 Sign in to vote
  3. 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
  4. I have had some issue with the Run method of the Wscript object not waiting for the application to finish.
  5. I am using Win2000, VisualStudio 6.0 Enterprise edition SP 5.
  6. 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
  7. Compactness of the open and closed unit intervals Send form result back to twig more hot questions question feed lang-vb about us tour help blog chat data legal privacy policy work

Wshshell Run Vs Exec

Are people of Nordic Nations "happier, healthier" with "a higher standard of living overall than Americans"? https://www.experts-exchange.com/questions/26228291/Call-exe-from-vbscript-wait-for-return-and-catch-return-code.html Bill Tuesday, September 04, 2012 2:26 AM Reply | Quote Moderator 0 Sign in to vote Bill - WBAdmin does not exit with those code. Vbscript Run Return Code undo a gzip recursively Ultimate Australian Canal Movie about a girl who had another different life when she dreamed more hot questions question feed about us tour help blog chat data Vbscript Run Command Get Output The active window remains active. 5 Activate & Restore. 6 Minimize & activate the next top-level window in the Z order. 7 Minimize.

It looks like you're new here. this content Google says... Thanks for the help, Chris. Join the community of 500,000 technology professionals and ask your questions. Wscript.shell Run Return Code 1

Microsoft Customer Support Microsoft Community Forums Script Center   Sign in United States (English) Brasil (Português)Česká republika (Čeština)Deutschland (Deutsch)España (Español)France (Français)Indonesia (Bahasa)Italia (Italiano)România (Română)Türkiye (Türkçe)Россия (Русский)ישראל (עברית)المملكة العربية السعودية (العربية)ไทย (ไทย)대한민국 (한국어)中华人民共和国 If I understand your question you want the WScript to return the return value of the command.bat to that end you can do this: var WshShell = WScript.CreateObject("WScript.Shell") var bat_return_value = It is a Microsoftutilitiy and it returns standard Microsoft error codes. -1 and -02 are not MS error codes. weblink Detect MS Windows Why are copper cables round?

As I said, that's a question to be asked in a different forum. Vbscript Return Code Terms of use / Privacy statement / Publisher: Lars Hagelin Programmers Heaven articles / Programmers Heaven files / Programmers Heaven uploaded content / Programmers Heaven C Sharp ebook / Operated by Last modified Nov 11, 2009 at11:35PM Comments closed Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please

Thanks for the help, Chris.

TakadaT, for responding first you get the extra point. 0 Featured Post How to improve team productivity Promoted by Quip, Inc Quip adds documents, spreadsheets, and tasklists to your Slack 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 asked 5 years ago viewed 30104 times active 3 years ago Linked 2 JScript: how to run external command and get output? 1 VBScript - Capturing output from stdout 0 VBA Wscript.shell Methods Try this one: Const WshFinished = 1 Const WshFailed = 2 strCommand = "ping.exe 127.0.0.1" Set WshShell = CreateObject("WScript.Shell") Set WshShellExec = WshShell.Exec(strCommand) Select Case WshShellExec.Status Case WshFinished strOutput = WshShellExec.StdOut.ReadAll

In any case this is not a scripting question. The first step is always read the docs and when they are silent, the second step is to ask your friends. How do I go about resolving these mysteries? check over here I've originally tried the code you suggested even before I entered this forum.

Bill Proposed as answer by Bill_StewartModerator Tuesday, September 04, 2012 11:33 PM Tuesday, September 04, 2012 12:55 AM Reply | Quote Moderator 0 Sign in to vote Bill - WBadmin is You can use various API calls to find stuff out about processes, but it's a lot more hassle than it should be. Written and compiled by Réal Gagnon ©1998-2016 [ home ]

Discussions Best Of... The active window remains active. 8 Display the window in its current state.

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 The docs don't give any details of the status code from the "run" command; I've looked. Already tried earlier, it doesn’t work Content of C:\test1.bat @echo off echo %DATE% %TIME% echo [[[[[[[[[[[ Testing Completed ]]]]]]]]]]]]]]] exit /b 333 Content of C:\test0.bat Shell() returns a task ID (what the rest of the world calls a Process ID).

Environment variables within the argument strCommand are automatically expanded. Invisible.vbs This one line VBScript can be used to run a command in an invisible window: CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False ' An example running 'Demo.cmd' with invisible.vbs I've called WshShell.Run(command.bat, 1, true), but it always returns exit code 0. Last modified Nov 11, 2009 at5:23PM adhamit Sven Groot said: adhamit said: *snip* I don't understand the question.

What is the meaning of the return codes -1 and -2? This is because of the 'True' at the end. Exit code of the application run via runas? 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

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 It is wise to add an error trap, because the Shell function can throw an exception if the program cannot be found or open for some reason. 0 · Share on Bill Monday, September 03, 2012 11:52 PM Reply | Quote Moderator 0 Sign in to vote What about this: Wscript.Shell.Run is not a legitimate jscript line of code unless you have If the oShell.run actually waits, then I don't need to do the objWMIService.Execquery.

More importantly, how do I go about diagnosing this?