Vbscript Run Return Code
That line of code cannot execute a run command. 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 Is there a reason why similar or the same musical instruments would develop? At the end of the lines above, the iReturn will be set to the return code from C:\someapp.exe. weblink
I have concluded that -1 means something issyntacticallywrong with the command, so I have to assume that WBAdmin is returning these values and this is probably not really a scripting question Get 1:1 Help Now Advertise Here Enjoyed your answer? 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 Search Comments Spacing RelaxedCompactTight Layout NormalOpen TopicsOpen AllThread View Per page 102550 First Prev Next re: Member 1141270229-Jan-15 9:07 Member 1141270229-Jan-15 9:07 yes he is right, script errors out
Vbscript Run Return Code
If this is the case, maybe you can run just the someapp.exe, without %comspec% /c preceding it. more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed Set objShell = CreateObject("WScript.Shell") comspec = objShell.ExpandEnvironmentStrings("%comspec%") ' //////////////////////////////////////////////////////// Set objExec = objShell.Exec(comspec & " /c ipconfig") Do WScript.StdOut.WriteLine(objExec.StdOut.ReadLine()) Loop While Not objExec.Stdout.atEndOfStream WScript.StdOut.WriteLine(objExec.StdOut.ReadAll) We expand the %comspec% variable (it returns the location of the command-line interpreter of Windows).
Why would two species of predator with the same prey cooperate? I found the code I posted as a response to the "normal" call not working properly. Not the answer you're looking for? Shell.run Error Codes 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
Hope this helps, Daz. 0 How to run any project with ease Promoted by Quip, Inc Manage projects of all sizes how you want. Vbscript Exec Edited by cjm51213 Tuesday, September 04, 2012 12:56 AM Tuesday, September 04, 2012 12:39 AM Reply | Quote 0 Sign in to vote Hi, What I have been trying to say I eventually found how to make my script work outside of this forum. 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
If I use strReturn = objShell.Run(cmd) WScript.Echo strReturn It always return 100 If I use On Error Resume Next WScript.Echo Err.Number It always return 0 Best Regards,
The script provided here will take … Citrix MS Applications MS Access VB Script Python Programming: If Statements Video by: Dototot Learn the basics of if, else, and elif statements in have a peek at these guys The fact that these are not Win32 error codes doesn't mean a program can't use them as exit codes. 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. 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, Wscript.shell Run Return Code 1
Thanks for the help, Chris. Why do I get a -2 with a scripting shell but an apparentlysuccessful execution when run from a command prompt? However, if you launch a windowed application such as calc.exe, you would need a loop since the command line would return before the program execution ended. check over here WshShell.Run Run an external Command.
Set objShell = CreateObject("WScript.Shell") objShell.run("cscript C:\scripts\demo.vbs") “Tell the truth and run” ~ Yugoslavian proverb Related: .Exec - Execute command, returning an object .ShellExecute - Run an application in the Windows Shell Wscript.shell Exec Stdout 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? Typically, here is how it should work.
Your problem is most likely that your someapp.exe runs outside of the cmd window that calls it.
You can read that question (Question ID (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http… VB Script Deploy and update a Microsoft Access application in a Citrix environment Article by: Gustav Deploying a Microsoft Access application The code below return me 100if there is an error and 0 if success. For Windows 9x users, command.com will be called. Method 'run' Of Object 'iwshshell3' Failed" 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
TechNet Products IT Resources Downloads Training Support Products Windows Windows Server System Center Browser Office Office 365 Exchange Server SQL Server SharePoint Products Skype for Business See all products So we know that in your case, r is the exit code from wbadmin.exe. 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 this content In any case this is not a scripting question.
Syntax objShell.Exec (strCommand) Key objShell A WScript.Shell object strCommand The Command to be executed Unlike .Run method, .Exec returns an object which returns additional information about the process started. It returns 0 (meaning Running) Fixed at stackoverflow.com/questions/32920690/… –ChrisJJ Oct 19 '16 at 22:23 | show 1 more comment Your Answer draft saved draft discarded Sign up or log in Digital Hardness of Integers From zero to parabola in 2 symbols Why leave magical runes exposed? asked 5 years ago viewed 30098 times active 3 years ago Linked 2 JScript: how to run external command and get output? 1 VBScript - Capturing output from stdout 0 VBA
Your original code had %comspec% /c in the run line, and did not have the iReturn= in the beginning. You cannot access teh shell withthat line of code. If the oShell.run actually waits, then I don't need to do the objWMIService.Execquery. Could it be related to Windows XP vs Windows 7 or the script host you are using?Thank you,Kevin Sign In·ViewThread·Permalink Re: Thank you Eduardo Mozart de Oliveira27-Jan-14 10:57 Eduardo Mozart
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 Hi, I don't use that utility, but there's not a rule that all command-line programs must exit with a valid Win32 error code value; it's merely a very widely followed convention. This tip pretends to show you the right choicedepending on your objective and program you are calling. IntroductionWhen I started programming in VBScript, I didn't know the real difference between Run and Exec in VBScript present in the WScript.Shell object.I'm writing this tip to help you to know
I'll fix it soon). For example: if you have Windows x64, C:\Windows\system32\cmd.exe (64-bits CMD) will be called, not C:\Windows\SysWow64\cmd.exe (32-bit version). Specify this flag when restoring a minimized window. 10 Sets the show-state based on the state of the program that started the application. windows-server-2012 wsh share|improve this question edited Jun 11 '14 at 10:03 Noelkd 3,70521734 asked Sep 27 '13 at 8:52 Krasi Kalincheva 12 add a comment| 1 Answer 1 active oldest votes
Why couldn't you post teh real code that was an issue. 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 The viewer will use a small PHP class to learn and create a watermark. Browse other questions tagged windows-server-2012 wsh or ask your own question.
Bill Tuesday, September 04, 2012 2:26 AM Reply | Quote Moderator 0 Sign in to vote Bill - WBAdmin does not exit with those code. Note: Some programs do not support real-time output (WGet and DISM are examples). I ran "WBAdmin get disk[s]" as both a limited user and an administrative user.