Given the nature of our deployment, it's easier for us to do sysprep as a post-installation task. I've successfully made a batch file that copies the unattended file and runs sysprep. However, I need to figure out how to run additional scripts after the sysprep (mainly our kbox agent, and wsname). Our naming convention is D+Servicetag for desktops, and L+servicetag - so the bulit in renaming in the sysprep unattended file won't work for us. Is there a way to run scripts after that at all?

Answer Summary:
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

4

look at this link to add commands to run on startup:

http://social.technet.microsoft.com/Forums/en-US/w7itproinstall/thread/96af91b6-4468-4e18-a029-37ef38677979

the section to add to sysprep would be

  <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <FirstLogonCommands>
<SynchronousCommand wcm:action="add">
          <CommandLine>call \\server\share\file.bat</CommandLine>
          <Order>1</Order>
          <RequiresUserInput>false</RequiresUserInput>
        </SynchronousCommand>
  </FirstLogonCommands>

Answered 06/18/2012 by: SMal.tmcc
Red Belt

  • I tried adding that to the end of my script (and instead of from the network, I called it from a file on the C:\ drive). I'll have to play with this some more.
  • You could try poking the run once registry enty instead of calling a batch file with this command (reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v task1 /d "c:\temp\task1.exe"
Please log in to comment

Answers

3

What is in the res.bat?

Answered 06/19/2012 by: SMal.tmcc
Red Belt

  • I don't recall the specific command off hand, but it changes the resolution. However, once I take that out, the other scripts run.

    The problem I'm having now, is renaming the PC with WSNAME, then joining the domain. I want to use WSNAME to rename, and a VBE file to join a domain. The domain joining works fine - however, the WSNAME isn't working for some reason...and it's always worked for us in the past. Here is our WSNAME command:

    wsname.exe /n:L$SERIALNUM /rcid /user:cusd200\pctech /pass:XXXX /DELETEEXISTING

    Now, if we use this command and it's not on the domain already, it won't have a problem, right? It only checks to delete it if already on the domain?
    • is cusd200 your domain? if it is and you are not on the domain then the problem is the user name is a domian user.
  • That bat is created by the kace from a post installation batch task named res. What lines are in the task?
    I do not use wsname so hopefully dugullett has input. I know most other questions about wsname are pointed to http://www.kace.com/support/resources/kb/article/How-to-create-a-naming-rule
    and
    http://mystuff.clarke.co.nz/MyStuff/wsname.asp
  • I used WSNAME at my last job using the /N:$SERIALNUM switch. I would think using the /rcid switch would work. The machine would already need to be on the domain so that "cusd200\pctech" would have rights to rename. Reading the release notes it says that /DELETEEXISTING will "attempt" to delete. That wouldn't sit well with me. It could get messy. Joining the domain before naming, and then renaming is like "putting the cart before the horse".

    I think you are trying to over complicate the process. I would just stick with naming the computer with /n:L$SERIALNUM, and then joining the domain. As long as your naming convention is the same you will be ok.

    Take a look at http://www.kace.com/support/resources/kb/article/How-to-rename-a-computer-and-join-it-to-a-Windows-domain-Image-Deployment. This got me started when I first started using WSNAME.
Please log in to comment
2

Guys - thanks for all of your help. The res.bat caused the problem with not allowing other scripts to run. A few MSI's that worked before sysprep/batch converter didn't work after - but had to zip them up and call them from a batch file to get it to work. A couple broken ones - but figured it out. I ran into an issue after renaming the PC, rebooting, then joining the domain - sometimes it wouldn't join...and I figured that it wasn't connecting to the network fast enough and was failing - so I put a 300mb MSI to deploy after reboot before joining the domain to give it some time.

 

For now it looks like it's working :) I worked for 4 months to prepare this image w/o sysprep because our guys said we didn't need it. Then the day before we image we're told we need sysprep - so it gave me very little time to learn sysprep, test deploy, and still keep on target for my deadline of imaging these 800 laptops. We have 1,000 desktops coming in 3 weeks that I'll be better prepared for now thanks to all of your help

Answered 06/20/2012 by: sfigg
Red Belt

  • I am in an academic environment and we base our images on software licenses for deployment. I use an installer user and install all of my software and tweek everything from the user look, updaters, configuraion of browsers, program settings, etc. Then I sysprep and copy that profile to default so every user gets the setttings we want. Rarely I have to mass install any software after, if we do we do it with the K1000. If you get stuck with sysprep don't hesitate to ask, there are a lot of knowledgeable people on this site.
Please log in to comment
1

So you've uploaded an image to the K2, and running sysprep as a post install? I think I'm a little lost here. Maybe because it's the end of the day.

You should syprep, then upload the image, then configure all of your post install tasks. 

Sysprep will remove the name of your machine. 

Answered 06/18/2012 by: dugullett
Red Belt

  • I agree I have always syspreped then captured do not know of any reason to reverse the process.
  • It's possible they send out computers in the sysprepped format, much as we recieve them from a computer manufacturer? I would wonder what "the nature of our deployment" means.
  • That makes sense. If you were a VAR and sending units out I could see that.
  • Yes, I know - it's a bit weird and nonconventional. However, if we could use sysprep as a post-install task, it would just be easier for us. I'm having troubles right now deploying a sysprepped image to a machine, as none of the post-install tasks are working and I'm not sure why. This way, I've had all the scripts run, and a sysprep script at the end. Seems to work fine for me so far since we can't figure out why a sysprepped image won't run scripts after. And we use WIM images, so I can't browse/edit the image via the k2000 website either to check for the C:\windows\setup\scripts folder.
    • List your midlevel tasks, and post installs. I would be more concerned about your post install tasks not working.
    • FYI - To look at a WIM image you can load it with the imagex /mount command, make sure the disk you are mounting to has enough space if it is a large image.

      http://technet.microsoft.com/en-us/library/cc749447(v=ws.10).aspx
  • Also, our network guys have insisted that we join A.D. with sysprep. However, with the amount of locations/OU's that we have, that would mean a different sysprepped image per location/OU....and with all the new models we're receiving this Summer, it'll eat up our whole K2000 storage.

    Unfortunately for right now, I have 800 laptops to image by Friday and can't spend any more time trying to get scripts to run after a sysprepped image - so I'll have to test it afterwards for the 1,000 desktops we're getting next month.
Please log in to comment
1

Call your .bat files. To test you can take "res.bat" out and the post install tasks will continue.

Command Line:

call res.bat
Answered 06/19/2012 by: dugullett
Red Belt

Please log in to comment
0

Well in the long run we'd like to get to imaging in a half normal fashion lol. One of the things you might try is the post-install task to logon script converter. If someone would be kind enough to link that to him.

Also there are lots of scripted ways to join a domain. Everyone has their favorites.

Answered 06/19/2012 by: Tentacle Master
Fourth Degree Black Belt

  • http://www.kace.com/support/resources/kb/article/K2000-postinstall-task-converter
Please log in to comment
0

Use this to join to specific OU. This is a snippet of what I use. Save this as a .ps1 and enter "powershell.exe -nologo -executionpolicy bypass -WindowStyle hidden -noprofile -file script.ps1" in your command line.

$oupath = 'OU=Workstations, DC=DOMAIN, DC=ORG'

$username = "domain\Admin"

$password = ConvertTo-SecureString "password" -AsPlainText -Force

$cred = New-Object System.Management.Automation.PSCredential $username, $password

Add-Computer -domainname domain.org -oupath $oupath -Credential $cred -ErrorAction silentlycontinue

Add-Computer -DomainName domain.org -Credential $cred

 

Answered 06/19/2012 by: dugullett
Red Belt

  • This content is currently hidden from public view.
    Reason: Removed by user request
    For more information, visit our FAQ's.
Please log in to comment
0

you may want to look at this.

http://www.itninja.com/question/k2000-postinstall-task-converter

I have injected run once commands in my post install by doing this (this is the last line of my post install script)

start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v kclean /d "c:\kcleanup.exe"

Answered 06/19/2012 by: SMal.tmcc
Red Belt

Please log in to comment
0

WOW - Thanks for all the help guys. The postinsatll task converter isn't required, is it? 

Ideally, I want to capture a sysprepped image. I'll get my network guys to not require us to use sysprep to join AD. After sysprep is finished (it restarts during sysprep too), it should automatically run whatever scripts I have as post-install tasks right? None of my scripts require restarts other than a pc-rename...but I think we already have a working script for pc rename & join domain.

 

Sorry to sound stupid - I joined here a year ago, and they've always done images w/o sysprep or newsid...now, we're deploying 2,000 machines this Summer with Windows 7 and they found out why our KMS wasn't working - they never did sysprep :) So It's new to me too!

Answered 06/19/2012 by: sfigg
Red Belt

  • You want to get everything they way you like it. Updates and all. Don't install any software (use post installs for this). After that you will sysprep the image.
    Once you run sysprep after the reboot (depending on what you tell it to do), you will then PXE boot to the K2. From there you will capture the image.
    Once you uploaded it then add your pre and post install tasks in the K2. Start small to verify everything works.

    You can also check this out to explain the basics on sysprep http://theitbros.com/sysprep-a-windows-7-machine-%E2%80%93-start-to-finish
  • Thanks - Yeah I thought we did that correctly - but I wasn't getting post install tasks to work correctly and I can't figure out why. Is that solely because of the Windows\Setup\Scripts folder being there? (even though nothing is in it?). I checked before sysprepping, and that folder didn't' exist - i then ran sysprep with my unattended file, capture the WIM image, and it didn't run any post-install tasks when deploying it.
    • What midlevel tasks do you have set? Post them in the same order you have them in your image.
  • Kace uses c:\kace to put all the post install task in you want to look there not in the scripts directory (that is syspreps area) do post your tasks sounds like one is not running breaking the chain
Please log in to comment
This content is currently hidden from public view.
Reason: Removed by user request
For more information, visit our FAQ's.

This content is currently hidden from public view.
Reason: Removed by user request
For more information, visit our FAQ's.

-1

Since you are using WIM's.   A trick to save network bandwidth and k2000 diskspace you can store the Wim's on any windows server, they are not restricted to k2000 file system.  I have had the server crew create storage space on all the sites and I store my Wims at each site.  They created a share on the main storage server at each site named images$ and I have a K2000 domain user that has rights to these shares.  I created a subdirectory called imagestore in each share (required).  I Then used the KBE manipulator to create custom pxe boot environements that map the T: and W: drive to each of my storage spaces.  Now when I capture a sysprepped image I choose the proper boot to map the server I want it to go to.  When staff deploys, they pxe boot to the k2000 box, the machine gets it deployment orders from the k2000 and starts.  I remap the W drive as my first preinstall task to the needed storage to access the WIM 

net use w: /delete
net use w: \\ms-acad.tmccacad.tmcc.edu\images$ Password /user:tmccacad\K2000

The deployment starts on the K2000 and then it switches over to the storage server to copy the wim portion then switches back to the K2000.  95% of the workload is placed on the storage servers instead of the K2000.  I have had 120 images deploying from a single k2000 this way and I am still able to capture my next master even when they are imaging.  This also allows you access to the wims so you could use imagex commands to view or edit the file.

Answered 06/19/2012 by: SMal.tmcc
Red Belt

Please log in to comment
-1

FYI I just mounted the WIM with imagex, and it does NOT have this path:

 

C:\windows\setup\scripts

 

However, when I deploy it, the post-install scripts don't run after it's sysprepped. Any ideas??

Answered 06/19/2012 by: sfigg
Red Belt

  • Please post your mid level tasks.....
  • is there anything in the c:\kace directory and cut and paste your mid/post tasks like this
    I have combined all mine to one post install and here are my calls from the task:
    (passwords changed to xxxxxxxxx)

    post task:
    net start w32time

    %SystemRoot%\system32\w32tm /config /update /manualpeerlist:ntp.tmcc.edu /syncfromflags:manual

    start /wait net user administrator /active:yes
    start /wait net localgroup administrators f12master /add
    Start /wait net user administrator XXXXXXX

    start /wait cscript.exe -b c:\windows\w2d\join_domain.vbs tmccacad.tmcc.edu installer xxxxxxxxx 10.16.19.7

    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v AutoAdminLogon /d 1 /f

    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v AutoLogonCount /t REG_DWORD /d 2 /f

    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultDomainName /d tmccacad /f

    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultUserName /d installer /f

    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultPassWord /d xxxxxxxxx /f

    start /wait reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Enviroment" /v LSFORCEHOST /d ms-vdf.tmccacad.tmcc.edu /f

    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v Userinit /d "C:\Windows\system32\KUsrInit.exe," /f

    del C:\Users\Default\AppData\Local\Microsoft\Windows\*.log1 /f /q /a:hs

    del C:\Users\Default\AppData\Local\Microsoft\Windows\*.log2 /f /q /a:hs

    del C:\Users\Default\AppData\Local\Microsoft\Windows\*.blf /f /q /a:hs

    del C:\Users\Default\AppData\Local\Microsoft\Windows\*.regtrans-ms /f /q /a:hs

    del C:\Users\Default\AppData\Local\Microsoft\Windows\Explorer\*.* /f /q

    del c:\users\default\downloads\*.* /f /q /s

    start /wait cscript %SystemRoot%\System32\slmgr.vbs -ATO

    start /wait cscript "c:\program files\microsoft office\office14\ospp.vbs" /act

    "c:\program files\dell\cctk\x86\cctk.exe" bootorder --sequence=hdd.1,hdd.2,embnic,usbdev,cdrom --valsetuppwd=xxxxxxxxxx

    net user installer /delete

    cmd /c md "%allusersprofile%\Dell\KACE" & cmd /c move /y "%systemdrive%\KACE\k2000_deployment_info.conf" "%allusersprofile%\Dell\KACE\k2000_deployment_info.conf"

    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v kclean /d "c:\kcleanup.exe"
    • I'm more curious about the mid level ones. There's something there stopping it. I'm assuming since you are using WIM you have something like:

      WIM- Temp File Removal
      WIM- NAME_OF_WIM.wim
      WIM- WIN7 MBR

      What else do you have? What order are they in?
  • Agreed on those. I used to have the problem of it not coming out of sysprep and found it was calls in my post tasks stepping on each other so I added the start /wait and my post sysprep problems went away.
  • That's all I have. Same as above ^^

    I just ran it again, and it seems as if it runs the 1st script (sets resolution), then nothing else follows.

    Here is what I have in terms of C:\KACE

    Installcmds.bat:
    [code]%systemdrive%\KACE\bin\cmdhide.exe hide && cd %systemdrive%\KACE\Applications\185 && res.bat
    %systemdrive%\KACE\bin\cmdhide.exe hide && cd %systemdrive%\KACE\Applications\108 && cdbxp_setup_4.4.0.3018.msi /quiet
    %systemdrive%\KACE\bin\cmdhide.exe hide && cd %systemdrive%\KACE\Applications\103 && msiexec.exe /i cowriter.msi /quiet
    %systemdrive%\KACE\bin\cmdhide.exe hide && cd %systemdrive%\KACE\Applications\163 && msiexec.exe /i CUSD200.msi /quiet
    %systemdrive%\KACE\bin\cmdhide.exe hide && cd %systemdrive%\KACE\Applications\50 && msiexec.exe /i ampagent-5.3.53177-x86_kbox.cusd200.org.msi /quiet
    %systemdrive%\KACE\bin\cmdhide.exe hide && cd %systemdrive%\KACE\Applications\37 && Londomainjoin.vbe
    %systemdrive%\KACE\bin\cmdhide.exe hide && cd %systemdrive%\KACE\Applications\187 && wsname.exe /n:L$SERIALNUM /rcid /user:cusd200\pctech /pass:XXXX /DELETEEXISTING
    [/code]


    And within that, the POSTINSTALL.BAT:
    [code]rem check whether this is vista image
    set SYSPREP_FILE=""
    cscript C:\KACE\bin\check_image.vbs winversion
    set WINVERSION=%ERRORLEVEL%
    IF %WINVERSION% GEQ 6 (
    rem changes for vista image
    rem run post install tasks from sysprep setupcomplete.cmd
    set SYSPREP_FILE="C:\windows\setup\scripts\setupcomplete.cmd"
    md C:\windows\setup\scripts
    ) ELSE (
    rem run post install tasks from sysprep GuiRunOnce
    set SYSPREP_FILE=C:\sysprep\sysprep.inf

    )

    rem check whether the image is syspreped or not
    cscript C:\KACE\bin\check_image.vbs sysprep
    set SYSPREP=%ERRORLEVEL%
    set KEY=HKLM\TEMP_SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

    IF %SYSPREP% EQU 1 (
    rem sysprep integration enabled
    echo on >> %SYSPREP_FILE%
    IF %WINVERSION% LSS 6 echo [GuiRunOnce] >> %SYSPREP_FILE%
    echo %%systemdrive%%\KACE\InstallCmds.bat >> %SYSPREP_FILE%
    echo %%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\185 ^&^& res.bat >> C:\KACE\InstallCmds.bat
    echo %%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\108 ^&^& cdbxp_setup_4.4.0.3018.msi /quiet >> C:\KACE\InstallCmds.bat
    echo %%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\103 ^&^& msiexec.exe /i cowriter.msi /quiet >> C:\KACE\InstallCmds.bat
    echo %%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\163 ^&^& msiexec.exe /i CUSD200.msi /quiet >> C:\KACE\InstallCmds.bat
    echo %%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\50 ^&^& msiexec.exe /i ampagent-5.3.53177-x86_kbox.cusd200.org.msi /quiet >> C:\KACE\InstallCmds.bat
    echo %%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\37 ^&^& Londomainjoin.vbe >> C:\KACE\InstallCmds.bat
    echo %%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\187 ^&^& wsname.exe /n:L$SERIALNUM /rcid /user:cusd200\pctech /pass:XXXX /DELETEEXISTING >> C:\KACE\InstallCmds.bat
    ) ELSE (
    rem sysprep integration disabled
    reg load HKLM\TEMP_SOFTWARE C:\windows\system32\config\software

    reg add %KEY% /V 001 /T REG_EXPAND_SZ /D "cmd /c \"%%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\185 ^&^& res.bat\"" /F
    reg add %KEY% /V 002 /T REG_EXPAND_SZ /D "cmd /c \"%%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\108 ^&^& cdbxp_setup_4.4.0.3018.msi /quiet\"" /F
    reg add %KEY% /V 003 /T REG_EXPAND_SZ /D "cmd /c \"%%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\103 ^&^& msiexec.exe /i cowriter.msi /quiet\"" /F
    reg add %KEY% /V 004 /T REG_EXPAND_SZ /D "cmd /c \"%%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\163 ^&^& msiexec.exe /i CUSD200.msi /quiet\"" /F
    reg add %KEY% /V 005 /T REG_EXPAND_SZ /D "cmd /c \"%%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\50 ^&^& msiexec.exe /i ampagent-5.3.53177-x86_kbox.cusd200.org.msi /quiet\"" /F
    reg add %KEY% /V 006 /T REG_EXPAND_SZ /D "cmd /c \"%%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\37 ^&^& Londomainjoin.vbe\"" /F
    reg add %KEY% /V 007 /T REG_EXPAND_SZ /D "cmd /c \"%%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& cd %%systemdrive%%\KACE\Applications\187 ^&^& wsname.exe /n:L$SERIALNUM /rcid /user:cusd200\pctech /pass:XXXX /DELETEEXISTING\"" /F
    reg add %KEY% /V 008 /T REG_EXPAND_SZ /D "cmd /c \"%%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& md \"%%allusersprofile%%\Dell\KACE\" ^& move /y %%systemdrive%%\KACE\k2000_deployment_info.conf \"%%allusersprofile%%\Dell\KACE\k2000_deployment_info.conf\"\"" /F
    reg add %KEY% /V 010 /T REG_EXPAND_SZ /D "cmd /c \"%%systemdrive%%\KACE\bin\cmdhide.exe hide ^&^& rd /s /q %%systemdrive%%\KACE ^& %%systemdrive%%\kcleanup.exe ^& del /f /q %%systemdrive%%\kcleanup.exe\"" /F

    reg unload HKLM\TEMP_SOFTWARE
    )[/code]
  • This content is currently hidden from public view.
    Reason: Removed by user request
    For more information, visit our FAQ's.
  • The one thing I did notice was you have multiple msi's calling in one of your post tasks. Do all your lines in the post task that call msi's and exe's have start /wait in front of the command? Over time I combined many post tasks to one. Mine is posted above as an example
  • I just have scripts for each software I want to install. They are mostly MSI files, and I just give the msiexec.exe /i program.msi

    This has always worked for us on every image we've done - but having problems getting it to run on sysprepped.
    • Call your .bat files. To test you can take "res.bat" out and the post install tasks will continue.
  • The res.bat may be terminating and not returning to the main bat file. You can check by seeing what was being done in that bat is done or not. if it is and the second step is not that could be what's up. follow the trail of calls and see where is stops doing the things you told it to do. That is where your problem should be.
    You can also duplicate your post task(s) and add the start /wait in front of any msi or exe call to see if you had the problem I did.
Please log in to comment
Answer this question or Comment on this question for clarity