Home > Return Code > Vbs Get Return Code

Vbs Get Return Code


You have to "hook" the return code ("iReturn=oShell.run(shellCommand,1,True)") at the moment you launch it, you can't grab it after the fact. The Process.Name of "C:\SomeApp.exe" is going to be "SomeApp.exe" so your WMI query will never match anything and will ALWAYS give you a colProcesses.Count of 0. Microsoft reserves all rights associated with the materials on this site. X T h e s y s t e m i s o u t o f e n v i r o n m e n t s p a check over here

Word for disproportionate punishment? Register Now Question has a verified solution. The path to the executable I was trying to call had spaces, by adding Chr(34) to the beginning and end it took care of the spaces. Replace the numbers with your choice.

Wscript.quit 0

P T h e s y s t e m c a n n o t f i n d t h e f i l e % 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)Россия (Русский)ישראל (עברית)المملكة العربية السعودية (العربية)ไทย (ไทย)대한민국 (한국어)中华人民共和国 I have had some issue with the Run method of the Wscript object not waiting for the application to finish. If this is the case, maybe you can run just the someapp.exe, without %comspec% /c preceding it.

Description Every command or script returns with the status of execution, which is referred as return status or exit codes. T P a r a m e t e r f o r m a t n o t c o r r e c t - " % 1 " 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 Vbscript Return Value To Batch File Thanks, Scott 0 Comment Question by:cusas76 Facebook Twitter LinkedIn https://www.experts-exchange.com/questions/26228291/Call-exe-from-vbscript-wait-for-return-and-catch-return-code.htmlcopy LVL 10 Best Solution byTakedaT I was not giving an attitude, I was just stating that you had not responded to

vbscript share|improve this question edited Aug 19 '10 at 15:39 Rob 31.3k1688115 asked Oct 9 '08 at 12:32 Philip.ie 86811118 add a comment| 3 Answers 3 active oldest votes up vote All rights reserved. All rights reserved.Newsletter|Contact Us|Privacy Statement|Terms of Use|Trademarks|Site Feedback Log in Sign up! 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

How are water vapors not visible? Wscript.quit Example This content is currently hidden from public view. Great for personal to-do lists, project milestones, team priorities and launch plans. - Combine task lists, docs, spreadsheets, and chat in one - View and edit from mobile/offline - Cut down How to tell my parents I want to marry my girlfriend Custom ColorFunction for GeoGraphics plot with ReliefMap more hot questions question feed lang-vb about us tour help blog chat data

Vbscript Exit Code 1

Are the guns on a fighter jet fixed or can they be aimed? Answered 11/01/2014 by: p.d.das Please log in to comment VBScab 2 years ago Golly! Wscript.quit 0 T h e p r o g r a m w a s e n d e d . < C o m m a n d n o t i Vbs Errorlevel What's the male version of "hottie"?

H % 1 w a s u n e x p e c t e d a t t h i s t i m e . Ä A d u http://blackplanetsupport.com/return-code/return-code-38.html So Please help. 0 Comments [ + ] Show Comments Comments Please log in to comment Answers 0 Try WScript.Quit(1), WScript.Quit(2), WScript.Quit(3). WinZip Self extractor/Run WinZip Button i,Min or hide DOS window How do I check component GUID? So be it. Wscript.quit Not Working

http://msdn.microsoft.com/en-us/library/d5fk67ky.aspx 0 Message Author Comment by:cusas76 ID: 328933512010-06-01 Sorry, I thought I had attached it. The documentation says: "If set to true, script execution halts until the program finishes, and Run returns any error code returned by the program. Do I have to do this? this content any others?) do NOT reset ERRORLEVELbut that all the rest (real commands which do something) DO reset ERRORLEVEL on completionIs that right?

So that i can display in my vbscript? Vbscript Return String Thank you for your help. Not an error.For the above example, the function MyVBScriptCA is set to 3 in case of an error and to 1 in case of success.Regards,Cosmin Cosmin Pirvu - Advanced Installer TeamFollow

Content of C:\test.vbs Jobname = "C:\test1.bat" Set WshShell = CreateObject("WScript.Shell") -------YELLOW PORTION------------------------- 'Set WshExec = WshShell.Exec( Jobname ) 'ScriptResult = ScriptResult & "Exit code (" & WshExec.ExitCode & "),

Join Now For immediate help use Live now! Reason: Removed by member request For more information, visit our FAQ's. TakadaT, for responding first you get the extra point. 0 Featured Post Is Your Active Directory as Secure as You Think? Wshshell.run Return Code Question 0 Sign in to vote Hi, i am Calling a Batch File Through VB Script.

My test.vbs runs a batch file and that batch files creates a log file. Note: Environment variables are a set of dynamic named values that can affect the way, running processes will behave on a computer. I am now curious if using the code I originally posted if I can get the return code from the oShell.run after the loop. have a peek at these guys blog comments powered by Disqus If you find this site useful, consider making a small donation to show your support for this Web site and its content, tia!

For example, an environment variable with a standard name can store the location that a particular computer system uses to store user profile this may vary from one computer system to This content is currently hidden from public view. with createobject("Wscript.Shell") nReturnErrorLevel = .run("%comspec% /c yourbatch.cmd", 0, True) end with wsh.echo "Errorlevel on return was:", nReturnErrorLevelTom Lavedas Marked as answer by LikeToCodeModerator Tuesday, January 11, 2011 1:53 AM Monday, use EXIT /B < exitcodes > at the end of the batch file to return custom return 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 H T h e b a t c h f i l e c a n n o t b e f o u n d . , % 1 f with createobject("Wscript.Shell") nReturnErrorLevel = .run("%comspec% /c yourbatch.cmd", 0, True) end with wsh.echo "Errorlevel on return was:", nReturnErrorLevelTom Lavedas Marked as answer by LikeToCodeModerator Tuesday, January 11, 2011 1:53 AM Monday, Thanks.

All rights reserved. For example:Code: Select allif StrData <> 0 then
MyVBScriptCA = 3
Exit Function
end if

MyVBScriptCA = 1
Exit Functionwhere MyVBScriptCA is the main function of your custom I found the code I posted as a response to the "normal" call not working properly. Setting it to True means wait, while False means dont wait.

As a convention, an ERRORLEVEL at 0 means a SUCCESS (255 is the maximum value). Detect ASCII-art windows made of M and S characters how to stop muting nearby strings or will my fingers reshape after some practice? It does this via a command line interface, making it suitable … Document Imaging Document Management Adobe Acrobat Scripting Languages Programming Advertise Here 656 members asked questions and received personalized solutions Function MyVBScriptCA() run the batch file read/get XX from the log file and save it as StrData .........what is next?

Monday, January 10, 2011 9:18 PM Reply | Quote Answers 0 Sign in to vote The Run function will return the error level of the underlying process if the bWaitonReturn (third) Have you read the documentation for the Run method of the WScript.Shell object? Imagine that! Therefore if my answer works for you, please distribute some points to TakedaT too.

What do you call this alternating melodic pattern? how do i can retrieve the errorlevel from my batch??? Typically, here is how it should work. Can I, and how do I, return an int return value to indicate success or failure?