Call script which stop/start windows service MDT 2012 Post OS Install TS

Answered Call script which stop/start windows service MDT 2012 Post OS Install TS

  • Thursday, December 13, 2012 8:58 AM
     
     

    I have .cmd script located on remote share with three lines of code:

    net stop nameofservice

    xcopy certain files

    net start nameofservice

    I called this .cmd script via Run Command Line step in MDT 2012 Post OS Install TS with option to run this step with domainname\administrator account but it failed. When I call this script manually with run as administrator option everything is OK. I need to solve this in order to automate windows 7 deployment with installing apps.

    Thanks in advance!!!

All Replies

  • Thursday, December 13, 2012 9:48 AM
     
     Answered

    How are you running the script? post your command line pls.

    The usual way for running a batch file is cmd /c %SCRIPTROOT%\mybatch.cmd


    Blog: http://scriptimus.wordpress.com

    • Marked As Answer by BoxiKG Thursday, December 13, 2012 5:18 PM
    •  
  • Thursday, December 13, 2012 12:12 PM
     
     

  • Thursday, December 13, 2012 12:33 PM
     
     Proposed Answer

    I would normally copy the script to the deployment share\scripts folder. Then run it from there. If your script is copying files from a network resource then you would still need to run this as your service account.

    When you say "it failed" could you be more specific? Is there an error returned? does the Task Sequence hang etc?


    Blog: http://scriptimus.wordpress.com

    • Proposed As Answer by DCtheGeek Thursday, December 13, 2012 4:26 PM
    •  
  • Thursday, December 13, 2012 12:41 PM
     
     

    I tested your advice and it worked (even without run as). Thank you very much Barnes. May I ask you something else?

  • Thursday, December 13, 2012 4:19 PM
     
     
    Sure. Ask away. (Remember to mark above as answer)

    Blog: http://scriptimus.wordpress.com

  • Thursday, December 13, 2012 5:34 PM
     
     

    My company bought 150 brand new HP Compaq 6300 Pro SFF computers with preinstalled Windows 7 x64 SP1 and some apps. However there is only C partition which consumes whole hard disk space (around 450 GB). After logging to computer for the very first time I can shrink that partition to wanted size (150 GB) via Disk Management or via diskpart tool. But I want to automate partitioning process so I have decided to put commands to shrink C partition and create and format D partition in .txt file and call this .txt file with Run Command Line step: diskpart /s path to this .txt file in MDT Post OS Install TS. When I tried this in test shrink failed.

    In Disk Management I saw that minimum space of C partition was around 225 GB, so I could not shrink it to 150 GB. In .txt first three lines are:

    select disk 0

    select volume 2

    shrink desired=315205 (to get partition of 150 GB)  and it failed in this step!!!

     
  • Thursday, December 13, 2012 11:01 PM
     
     

    That usually happens because of where the data is located. A defrag with consolidate space before the shrink should resolve this.

    Problem is that it's time consuming also.

    I'd wipe the disk and load your own image if possible.


    Blog: http://scriptimus.wordpress.com

  • Friday, December 14, 2012 7:13 AM
     
     

    Yes, I tried defrag and it took too much time so I aborted operation. But still I do not understand why before running diskpart /s file.txt I could shrink partition to 150 GB. Two lines before shrink command in .txt file only select disk and volume to shrink, nothing else. If I had not been able to shrink partition before running diskpart /s file.txt I would not try to run diskpart /s at all.

    On first 10 computers I did shrinking to 150 GB but in Disk Management, but I want to do this by using MDT 2012 Run Command Line step in Post OS Install TS. This should be straightforward process since I only need to shrink c partition and create and format d partition from unallocated space on hard disk.