locked
batch output during OSD RRS feed

  • Question

  • Hi,

    during OSD I need to see the actual output of a batch file I'm executing after applying the OS image, so I can see if and where it fails

    or if it asks for user interaction. Is there a way to do so?

    Thanks

    Monday, April 29, 2013 3:26 PM

Answers

  • It might be a bit tricky, or not. This is what I think is correct to your situation...

    I think that if the TS is initiated from SCCM using a mandatory advertisement or using the ”run advertise programs” then you might not be able to view it without some serious fiddling. This is due to the TS running in session 0 and you viewing in another session. Here is some information on how to get around this... http://blogs.technet.com/b/cameronk/archive/2010/04/27/creating-a-user-interactive-task-sequence-experience.aspx

    If the TS was initiated using boot media such as USB then you are already in session 0 so from what I can see then it’s possible to interact with the TS without issue....

    In which case you could try using a VB script to starts the batch file...

    set objshell = wscript.createobject("wscript.shell")

    objshell.run "cmd /k C:\Path to my batch file", 1, true

    Using the /k will keep the command window open so the task sequence won’t actually continue passed this point but you can see what's causing the failure.

    It that doesn't work then you could always create a software distribution package to run the batch file out side of a task sequence to see what the issue is. On the environment tab of the program you can have run with administrator rights and "allow users to interact with this program". Place a pause at the end of the batch file so it stays on screen so you can see the errors. Once your happy that the batch file works using software distribution you can add it back into the task sequence and it should work there too.

    Last but not least, for each line on your batch file end it with >> C:\Batch.log

    As already mentioned in this post it will output the results of the execution for that line into C:\Batch.log

    Good luck

     

    Just wanted to update this as there is now a tool that is included on MDT 2012 that allows you to launch things in Session 1 and therefore you will be able to see any dialogs, errors etc which ever way the task sequence is initiated.

    download MDT 2012 SP1 and install it and then find the ServiceUI.exe that's buried in the Programs Files \ MDT directory. You can use this in the task sequence tp launch the batch, eg  this command

    %~dp0\ServiceUI.exe MyBatchfile.cmd




    Tuesday, April 30, 2013 8:11 AM

All replies

  • You can output to log using >> after the command.

    See: http://www.msfn.org/board/topic/21611-how-to-capture-batch-file-output-in-log-file/ for an example.

    Here's a little sample of what the batch could look like that installs a MSI and writes log to %temP%\mylogfile.log:

    echo %DATE% %TIME% info: About to perform some action ... >>%Temp%\MyLogFile.log

    msiexec /i "%~dps0MYMSIINSTALLER.MSI"

    echo %DATE% %TIME% info: Action complete error code is %ErrorLevel% >>%Temp%\MyLogFile.log


    Justin Chalfant | Blog: setupconfigmgr.com | SCUP Catalog: patchmypc.net/scup | Please mark as helpful/answer if this resolved your issue

    Monday, April 29, 2013 3:57 PM
  • HI Justin,

    sorry I didn't explain very well what I want, I need to see the cmd window of my running batch so I can interact with it if needed.

    Thank you

    Tuesday, April 30, 2013 6:39 AM
  • It might be a bit tricky, or not. This is what I think is correct to your situation...

    I think that if the TS is initiated from SCCM using a mandatory advertisement or using the ”run advertise programs” then you might not be able to view it without some serious fiddling. This is due to the TS running in session 0 and you viewing in another session. Here is some information on how to get around this... http://blogs.technet.com/b/cameronk/archive/2010/04/27/creating-a-user-interactive-task-sequence-experience.aspx

    If the TS was initiated using boot media such as USB then you are already in session 0 so from what I can see then it’s possible to interact with the TS without issue....

    In which case you could try using a VB script to starts the batch file...

    set objshell = wscript.createobject("wscript.shell")

    objshell.run "cmd /k C:\Path to my batch file", 1, true

    Using the /k will keep the command window open so the task sequence won’t actually continue passed this point but you can see what's causing the failure.

    It that doesn't work then you could always create a software distribution package to run the batch file out side of a task sequence to see what the issue is. On the environment tab of the program you can have run with administrator rights and "allow users to interact with this program". Place a pause at the end of the batch file so it stays on screen so you can see the errors. Once your happy that the batch file works using software distribution you can add it back into the task sequence and it should work there too.

    Last but not least, for each line on your batch file end it with >> C:\Batch.log

    As already mentioned in this post it will output the results of the execution for that line into C:\Batch.log

    Good luck

     

    Just wanted to update this as there is now a tool that is included on MDT 2012 that allows you to launch things in Session 1 and therefore you will be able to see any dialogs, errors etc which ever way the task sequence is initiated.

    download MDT 2012 SP1 and install it and then find the ServiceUI.exe that's buried in the Programs Files \ MDT directory. You can use this in the task sequence tp launch the batch, eg  this command

    %~dp0\ServiceUI.exe MyBatchfile.cmd




    Tuesday, April 30, 2013 8:11 AM