Jump to content
Sign in to follow this  
surreal

winpe - sysprep - dell service tag

Recommended Posts

surreal

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 by surreal

Share this post


Link to post
Share on other sites
LarryDalooza

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.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites
surreal

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

Share this post


Link to post
Share on other sites
LarryDalooza

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.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites
surreal

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

Share this post


Link to post
Share on other sites
ProgAndy

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 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

Share this post


Link to post
Share on other sites
LarryDalooza

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" )


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites
surreal

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.