Jump to content

Need script to modify sysprep.inf


Recommended Posts


And here I thought I had it all worked out!! :angry:

OK, the script works if Windows is up & running and I go to my Sysprep folder (as administrator) and double click the mac.bat script. It echoes the correct Machine name & Product key and even modifies my sysprep.inf file. However, If I try to do it automated by adding the following:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]

"Sysprep"="C:\\Sysprep\\mac.bat"

The script launches and I see the command windows before the Desktop icons appear, and then in the command window, it says "System can not find ..." so If I close it out, wait for the desktop icons to appear as well as the Local Area Network Icon to appear by the clock, and double click on it, then it works.

I'm guessing it needs to wait for the stupid Marvell Yukon built in network card to initialize or something....

Is there a way to delay launching the script, so that it starts after windows is completely initialized (dektop icons & all) ??

Link to comment
Share on other sites

I kept getting the following crap only when the mac.bat was ran automatically:

The system cannot find the file specified.

The system cannot find the file specified.

Computer Name should be:

Product Key should be:

Now editing Sysprep.inf

'Fedit' is not recognized as an internal or external command

When I ran the .bat manually by double clicking it, it ran fine.

Apparantly the command window and Microsoft Windows in general are Retarted!

I was finally able to get it to work with the following:

@echo off
PATH c:\Sysprep;C:\Windows\System32;C:\Windows\System32\wbem
TITLE Sysprep Customizer
ECHO Waiting for NIC to initialize...
ping -n 15 localhost> NUL
ECHO Determining Machine Name and Product Key...
ECHO.
CD \
CD Sysprep
For /f "usebackq delims=," %%i IN (`getmac /fo csv /nh`) do (
For /f "usebackq delims=, tokens=1-3" %%a IN (`type mac.txt`) DO If %%i EQU %%a (
Set strComputername=%%b
Set strProduct=%%c
) )
Echo Computer Name should be: %strComputername%
Echo Product Key should be: %strProduct%
ECHO Now editing Sysprep.inf ...
SET T1=Fedit -add -once -f Sysprep.inf -s UserData
%T1%  ComputerName=%strComputername%
%T1% ProductKey=%strProduct%
ECHO [UserData] section completed...
ECHO Removing Startup Entry...
REG DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Sysprep /f
ECHO About to Sysprep System...
REM  ** SYSPREP COMMAND HERE **
CLS
EXIT

Edited by Thinkster
Link to comment
Share on other sites

Not sure on this, but knowing how picky everything else has been with names/paths, etc., it probably has to have quotes around the Product key.

Per Ref.chm, it shows: Syntax ProductKey = "xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"

in the [userData] section of Sysprep.inf

the script above does add ProductKey to the correct secion of sysprep.inf, but the product key is not in quotes " ".

So last favor! is there an easy way to add the quotations in there so when

echo'ing or writing the variable %strProduct% that it shows like this:

"xxxxx-xxxxx-xxxxx-xxxxx-xxxxx" rather then xxxxx-xxxxx-xxxxx-xxxxx-xxxxx

I've tried doing this:

set xx="

set pk=%xx%%strProduct%%xx%

Echo Product Key should be: %pk%

SET T1=Fedit -add -once -f Sysprep.inf -s UserData

%T1% ProductKey=%pk%

Which Echo's it correctly with "Quotes", but when written to sysprep.inf using Fedit, the quotes are not there. So I'm thinking this may be a problem with Fedit that it can't handle quotes...

Or does anyone for sure know if this really matters when minisetup looks for the product key in the sysprep.inf file?

Edited by Thinkster
Link to comment
Share on other sites

Don't use Fedit at all: Simple divide the sysprep.inf in 2 parts at [userData] section

sysprep1.inf

sysprep3.inf

ECHO Now editing Sysprep.inf ...
ECHO ComputerName=%strComputername%>sysprep2.inf
ECHO ProductKey="%strProduct%">>sysprep2.inf
COPY /b sysprep1.inf + sysprep2.inf + sysprep3.inf sysprep.inf
ECHO [UserData] section completed...

Use more pieces if ProductKey goes in another section.

Link to comment
Share on other sites

Don't use Fedit at all: Simple divide the sysprep.inf in 2 parts at [userData] section

sysprep1.inf

sysprep3.inf

ECHO Now editing Sysprep.inf ...
ECHO ComputerName=%strComputername%>sysprep2.inf
ECHO ProductKey="%strProduct%">>sysprep2.inf
COPY /b sysprep1.inf + sysprep2.inf + sysprep3.inf sysprep.inf
ECHO [UserData] section completed...

Use more pieces if ProductKey goes in another section.

Yes, that seems to work!! I made the following changes though:

ECHO ComputerName=%strComputername%>>userdata.inf

ECHO ProductKey="%strProduct%">>userdata.inf

COPY /b sysprep1.inf + userdata.inf sysprep.inf

My sysprep1.inf contains everything but the [user Data] section

my userdata.inf contains only

[user Data]

FullName="Some Department"

OrgName="Some Organization"

And a carriage return after the orginization name.

The lines of code you gave added the Machine Name & Product Key in Quotes (Yay!) to the User Data section and the copy combined the stuff like it should have!

Regarding the errors I had before with "...not found." I think what I added:

PATH c:\Sysprep;C:\Windows\System32;C:\Windows\System32\wbem

CD \

CD Sysprep

fixed that issue...

Thanks again to all those who helped on this!!

Link to comment
Share on other sites

  • 2 weeks later...

If you run this on a bas machine wont the serial number be incorrect for subsequent machines? Im trying to use compname.exe like this compname.exe /? ?s to get the serial number and use it as the computername. If you do this on a base machine wont the serial number be wrong for all subsequent machines ?

Thanks,

Link to comment
Share on other sites

@Viper999:

WTF compname.exe is?

Try MAC adresses first, then replace all instances of GetMac with compname.exe

Here we relies on NIC MAC adresses uniqueness. But whatever compname.exe return should also work.

@Thinkster: Care to edit the first post with the final solution? This topic is becoming popular...

Link to comment
Share on other sites

  • 10 months later...

You guys are trying to reinvent the wheel here. Do a google search for "wsname". This little utility does everything you guys are wanting and more. I set the "ComputerName=*" in the sysprep.inf and then let this utility run in the cmdlines.txt to rename the computer account to the correct name.

Works great. I even set up a login script to collect MAC addresses and computer names to populate a file that can be used with "WSName". If anyone wants to see specifics I think I still have the files so I can show you.

Link to comment
Share on other sites

You guys are trying to reinvent the wheel here. Do a google search for "wsname". This little utility does everything you guys are wanting and more. I set the "ComputerName=*" in the sysprep.inf and then let this utility run in the cmdlines.txt to rename the computer account to the correct name.

Works great. I even set up a login script to collect MAC addresses and computer names to populate a file that can be used with "WSName". If anyone wants to see specifics I think I still have the files so I can show you.

:yes: share your knowledge!

Link to comment
Share on other sites

  • 2 months later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...