Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-31-2014, 05:11 AM
bdrc89 bdrc89 is online now
Registered User
 
Join Date: 07-30-2014
Posts: 6
Stopping on batch file error

Greetings, I am using the VBP to run batch files that triggers Powershell script remotely. However when the Powershell encounter errors, the VBP will continue execute the rest of the steps in the project. The error message from Powershell's console will appear in output window, but I would like VBP to treat it as error and stop running.
I have yet to find a workaround for this, please advice.
Reply With Quote
  #2  
Old 07-31-2014, 06:27 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Make sure that the batch file is exiting with a non-zero exit code when the PowerShell script fails, and use the Batch File action in Visual Build to call it, or include the call statement (i.e., %DOSCMD% call batchfile.bat) when running the batch file if calling directly (otherwise the exit code may not be returned to Visual Build).

http://www.microsoft.com/resources/d....mspx?mfr=true

https://stackoverflow.com/questions/...ering-an-error

https://stackoverflow.com/questions/...ograms#4825773

http://www.kinook.com/Forum/showthread.php?t=260
Reply With Quote
  #3  
Old 08-01-2014, 05:15 AM
bdrc89 bdrc89 is online now
Registered User
 
Join Date: 07-30-2014
Posts: 6
Thank you, would try out the remedy suggested. Much appreciated.
Reply With Quote
  #4  
Old 08-04-2014, 06:28 AM
bdrc89 bdrc89 is online now
Registered User
 
Join Date: 07-30-2014
Posts: 6
Hi again, I have tried to add throw error in PowerShell, and batch file exits with error code greater than 0. However when I call the batch file through VBP, it will stuck at Building... process. Note that the batch file to be called is located in remote machine.
Reply With Quote
  #5  
Old 08-04-2014, 09:06 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
It works in our tests. See the attached sample and log.
Attached Files
File Type: zip psbatch.zip (1.0 KB, 6698 views)
Reply With Quote
  #6  
Old 08-05-2014, 01:02 AM
bdrc89 bdrc89 is online now
Registered User
 
Join Date: 07-30-2014
Posts: 6
I ran the same batch file and vbp from the attachment, but placing them in a different machine from where the VBP resides, and it is stucked at executing the step.

I have use the batch file command script "%DOSCMD% call psbatch.bat" or "cmd /c 'echo . | psbatch.bat'". I am using this approach as I need to pass various parameters back to batch file.
Reply With Quote
  #7  
Old 08-05-2014, 05:40 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Quote:
Originally Posted by bdrc89 View Post
I ran the same batch file and vbp from the attachment, but placing them in a different machine from where the VBP resides, and it is stucked at executing the step.
It works on a different remote machine in our tests.
Reply With Quote
  #8  
Old 08-05-2014, 10:17 PM
bdrc89 bdrc89 is online now
Registered User
 
Join Date: 07-30-2014
Posts: 6
Could it be due to firewall setting? Remotely running the batch file works, but the exit code seems not able to catch, hence it stucks in execution state.

However when I tried to remotely execute the psbatch with command
"powershell -command" the VBP is able to show the error and shows program completed with exit code. But when adding "throw" into the batch file it will stuck in execution.
Reply With Quote
  #9  
Old 08-05-2014, 10:45 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
I wouldn't think so. At first, you said that Visual Build continues as if no error occurred, but more recently you say that Visual Build "stucks in its execution state", so I'm not sure exactly what's going on. From the sound of it, I would guess that PsExec is never finishing and Visual Build is waiting for it. Which version of PsExec are you using? Which version of Visual Build? Which version+SP of Windows on local and remote? Any more details you can provide (see http://www.kinook.com/Forum/showthread.php?t=3044) might help. Thanks.
Reply With Quote
  #10  
Old 08-06-2014, 11:02 PM
bdrc89 bdrc89 is online now
Registered User
 
Join Date: 07-30-2014
Posts: 6
I added start-process -PassThru in the batch file and get the ExitCode from Powershell, seems to be working in my test now.

Thanks for the assists along the way, much appreciated.
Reply With Quote
Reply

Tags
error , halt , powershell , vbp


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 05:52 PM.


Copyright © 1999-2023 Kinook Software, Inc.