Why do some scripts "succeed" but fail to run?
I'm referring specifically to running batch files from the task section of a script. I have an install script that is really just a small batch file and it keeps failing even when it shows as a success.
I'm having some K1000 scripting issues where the script will push the dependencies, but then fail to run them and still count it as a "run success."
Here's what I've done so far. First, I broke the single batch file up into separate files to segregate the commands and make sure they weren't tripping over each other. In the very first one, I put a few taskkill lines to end the processes of the application I'm trying to update. If I select "wait for completion" on this one then the script just fails outright and logs it as a run failure and, from what I can tell, rarely actually runs that batch file. I specifically routed the standard out and error to a text file for each line to see if it ran. Sometimes it does, sometimes it doesn't. But the script will never succeed if I mark any of the batch files as "wait for completion."
So the alternative is to not do that, which usually results in kbox copying over all the dependencies and then marking it as a run success without running any/all of the dependencies.
This is all done as the local system account. None of the batch files are trying to touch anything but the local machine. For the life of me, I cannot figure out why they often fail to even run.
I'm having some K1000 scripting issues where the script will push the dependencies, but then fail to run them and still count it as a "run success."
Here's what I've done so far. First, I broke the single batch file up into separate files to segregate the commands and make sure they weren't tripping over each other. In the very first one, I put a few taskkill lines to end the processes of the application I'm trying to update. If I select "wait for completion" on this one then the script just fails outright and logs it as a run failure and, from what I can tell, rarely actually runs that batch file. I specifically routed the standard out and error to a text file for each line to see if it ran. Sometimes it does, sometimes it doesn't. But the script will never succeed if I mark any of the batch files as "wait for completion."
So the alternative is to not do that, which usually results in kbox copying over all the dependencies and then marking it as a run success without running any/all of the dependencies.
This is all done as the local system account. None of the batch files are trying to touch anything but the local machine. For the life of me, I cannot figure out why they often fail to even run.
2 Comments
[ + ] Show comments
Answers (1)
Answer Summary:
Please log in to answer
Posted by:
KACE_Mary
10 years ago
The other thing I would add is that batch script is really not suited to any process where you want accurate error reporting. If your batch file completes then it will always return success regardless of whether any of the calls in the batch file returned an error, as the call itself has been successful. If you use VBScript, then you can more easily test each and every call to an external process for a specific return code.
Finally, you also don't mention what your target operating system is. This is where a copy of XP or XP64 can prove useful, as you can run stuff as system from a command line opened using the AT scheduler, and XP still supports interaction with desktop if you use the /interactive switch on the AT scheduler call to cmd.exe. This then allows you to see any error messages that your script throws up, which is unfortunately not possible for localsystem calls on Windows 7. - EdT 10 years ago
In my case, the batch was trying to access network resources and because I was running as local system it wasn't working (doh!). So running as a domain user worked.
If you made sure the batch works normally (by double clicking) then I suppose it could still be a permissions issue. To determine if it is indeed a permissions issue you might try running the batch normally (by double clicking) except logged in as a user with non-admin permissions. Then again with admin permissions. See if that makes a difference.
Let us know! - getElementById 10 years ago