Wshshell Run Vs Exec
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. If this is the case, maybe you can run just the someapp.exe, without %comspec% /c preceding it. This tip pretends to show you the right choicedepending on your objective and program you are calling.
Wshshell Run Vs Exec
Of course, as you correctly pointed out, all this is useless if the OP is not calling the WshShell object's Run method from JScript correctly in the first place. Then simply read the command line's output from the standard streams. Note: Some programs do not support real-time output (WGet and DISM are examples). 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
The fact that these are not Win32 error codes doesn't mean a program can't use them as exit codes. 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. Is it possible to get a professor position without having had any fellowships in grad school? Wscript.shell Exec Stdout Continue to Part 2 to learn the core code used in creat… PHP Web Development Web Languages and Standards Scripting Languages Advertise Here 612 members asked questions and received personalized solutions
I would like the exit code to be returned so I can use it to sleep the script until the program is completely installed before moving on. Vbscript Run Command Get Output Encyclopedia of mathematics (?) Is investing a good idea with a low amount of money? How do I create armor for a physically weak species? Exec We can use it to call GUI applications, because thenRun does not call CMD to execute the action.
All rights reserved. Vbscript Return Code Thanks for the idea! Here are a couple examples I tossed together using cmd or ping. 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
Vbscript Run Command Get Output
For example, if Word is installed on your computer system, calling Run on a *.doc file starts Word, and loads the document. I have had some issue with the Run method of the Wscript object not waiting for the application to finish. Wshshell Run Vs Exec If not, I can always use a sleep function, but I am trying to avoid this. Wscript.shell Run Return Code 1 If you insist on a custom wrapper then perhaps you can post the actual code that is being used.
Perhaps if people can't comment on why no return code, they can suggest ways to clean this up?? If wbadmin.exe does not return a consistent exit code, then of course you cannot use its exit code to determine whether it ran successfully. It will call the correct version of CMD.exe depending on the ARCH of your OS. Is it sufficient to simply run under theAdministrativeusername? Shell.run Error Codes
Personal loan to renovate my mother's home Confusion in fraction notation How do you remove a fishhook from a human? Wscript.shell Methods After you actually posted your code, I gave 2 more suggestions that have yet to get a response from you. PHV (MIS) 2 May 08 10:32 What about this ?rc = oWshell.Run("cmd /c " & CMD, DISPLAY_WINDOW, True) Hope This Helps, PH.FAQ219-2884: How Do I Get Great Answers To my Tek-Tips
The jscript construct is syntactically and functionally incorrect.
Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix This is easy to test, and I will test this first thing tomorrow and tell you want I learn. Uncomment if script does not run correctly.'WScript.Echo Laptop'exitcode echo to ensure variable was correctly set and passed out of "for" loop. Vbscript Return Value Because you will not post the real code there is no way to help you.
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 If you use the correct or at least usab;e ActiveX activation then teh returncode would be meaningful. if not, is there anyway that I could validate to see if my command has been run successful? If you haev an access error it will likely be a return of 5.
DPlank (IS/IT--Management) (OP) 2 May 08 09:42 Running with the Exec method has the same runtime error popping up... Many of these have come from the web or adaptations from snippets I find on the Web. Running from the command prompt, I am told I must be running withadministrativepermissions, so I am, but I suspect that I am not running my JScript as Administrator. When the program closes, VBScript will read all output from the prompt and write it on screen.
Generic immutable object builder Is there an equivalent for vim's \zs in sed or perl? Problem solved. And, I think we know that -1 = 0xFF (255) as an 8-bit integer, 0xFFFF (65,535) as a 16-bit integer, and 0xFFFFFFFF (4,294,967,295) as a 32-bit integer, so that translation doesn't Sign In·ViewThread·Permalink Re: Need assistance Eduardo Mozart de Oliveira16-Oct-16 5:38 Eduardo Mozart de Oliveira16-Oct-16 5:38 Yes, it will.
Edit - I've included my entire script. It is a Microsoftutilitiy and it returns standard Microsoft error codes. -1 and -02 are not MS error codes.