surreal Posted February 5, 2009 Posted February 5, 2009 (edited) hello everyone, below is a scenario of my process... 1. i create a sysprep xp image 2. capture the new syspreped image to a .wim using microsoft imagex 3. boot into winpe 2.0 and apply the new syspreped image with an imagex gui. 4. all of step three is unatteded, once done the user or tech can login to the new image. (except for the computer name part that sysprep asks for within mini setup) my first question is will autoit scripts work within winpe 2.0? i would assume so. i would like to name all new machines with the dell service tag. what im thinking is a script that would grab the service tag within winpe 2.0 after applying the new image then import he dell service tag into the c:\sysprep\sysprep.inf. winpe 2.0 is 32bit, and immediately after applying the image the c: drive is accessible. below is a few thoughts of code that i have, all help will be greatly appreciated... $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems IniWrite ( "C:\sysprep\sysprep.inf", "ComputerName=", $objItem.IdentifyingNumber ) Next Else IniWrite ( "C:\sysprep\sysprep.inf", "ComputerName=", "" ) Endif Exit at this time i get an error thanks again surreal Edited February 5, 2009 by surreal
LarryDalooza Posted February 5, 2009 Posted February 5, 2009 Win PE must have the scripting and WMI support. I forget how to incorporate it off the top of my head... just know that PE must have the scripting and WMI support. Other than that everything you mention is sound and the same as I have implemented on the job. Lar. AutoIt has helped make me wealthy
surreal Posted February 6, 2009 Author Posted February 6, 2009 thank you for the reply, i do have both of them tools installed into the winpe package, as well as hta and xml. the only problem now is this script is not working. it errors out on me everytime, maybe iniwrite is not the answer? surreal
LarryDalooza Posted February 6, 2009 Posted February 6, 2009 As long as the sysprep.inf is not "read only", it should work. Put some error checking in the script... If Not IsObj() ... and ... If @error kind of stuff... need to know where, specifically, the error is happening. Lar. AutoIt has helped make me wealthy
surreal Posted February 6, 2009 Author Posted February 6, 2009 ok im no longer getting the error with the below edited script. however it is now not doing what i need. within the sysprep file i have a the userdata string. [userData] ProductKey= FullName= OrgName= ComputerName= with the below script it deletes everything above and creates the below [userData] ComputerName=sdf6dsf <-----it is importing the dell service tag i can leave the computername= blank in sysprep if that would help, i tried that and it still deletes all the other entrys. here is the script. $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems IniWriteSection("C:\Sysprep\Sysprep.inf","UserData","Computername=" & $objItem.IdentifyingNumber) Next Else IniWriteSection("C:\Sysprep\Sysprep.inf","UserData", "Computername=") Endif Exit surreal
ProgAndy Posted February 6, 2009 Posted February 6, 2009 (edited) IniWriteSection deletes the old if it exists and writes the new one. You should use IniWrite. You have to use this command: IniWrite ( "C:\sysprep\sysprep.inf", "UserData", "ComputerName", $THEKEYVALUE ) -> define SectionName -> don't add = to Key Edited February 6, 2009 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
LarryDalooza Posted February 6, 2009 Posted February 6, 2009 my bad... I did not see this...IniWrite ( "C:\sysprep\sysprep.inf", "ComputerName=", $objItem.IdentifyingNumber )you are not using it right...IniWrite ( "filename", "section", "key", "value" ) AutoIt has helped make me wealthy
surreal Posted February 6, 2009 Author Posted February 6, 2009 that did the trick, thank you everyone... $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems IniWrite ( "C:\sysprep\sysprep.inf", "UserData", "ComputerName", $objItem.IdentifyingNumber ) Next Else IniWrite ( "C:\sysprep\sysprep.inf", "UserData", "ComputerName", "" ) Endif Exit surreal
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now