Martin Zugec Posted July 26, 2005 Share Posted July 26, 2005 You must have getmac.exe, which is shipped with OS... If you dont have it in Home, just copy it there... Link to comment Share on other sites More sharing options...
Thinkster Posted July 27, 2005 Author Share Posted July 27, 2005 And here I thought I had it all worked out!! 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 More sharing options...
Jito463 Posted July 27, 2005 Share Posted July 27, 2005 Well, you could add a delay into the script (30 seconds, 60 seconds, whatever works) so it waits for the desktop to load before actually running. Link to comment Share on other sites More sharing options...
Thinkster Posted July 27, 2005 Author Share Posted July 27, 2005 (edited) 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 commandWhen 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 offPATH c:\Sysprep;C:\Windows\System32;C:\Windows\System32\wbemTITLE Sysprep CustomizerECHO Waiting for NIC to initialize...ping -n 15 localhost> NULECHO Determining Machine Name and Product Key...ECHO.CD \CD SysprepFor /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=%%bSet 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 /fECHO About to Sysprep System...REM ** SYSPREP COMMAND HERE **CLSEXIT Edited July 27, 2005 by Thinkster Link to comment Share on other sites More sharing options...
Thinkster Posted July 27, 2005 Author Share Posted July 27, 2005 (edited) 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.infthe 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 whenecho'ing or writing the variable %strProduct% that it shows like this:"xxxxx-xxxxx-xxxxx-xxxxx-xxxxx" rather then xxxxx-xxxxx-xxxxx-xxxxx-xxxxxI'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 July 27, 2005 by Thinkster Link to comment Share on other sites More sharing options...
Nilfred Posted July 29, 2005 Share Posted July 29, 2005 Don't use Fedit at all: Simple divide the sysprep.inf in 2 parts at [userData] sectionsysprep1.infsysprep3.infECHO Now editing Sysprep.inf ...ECHO ComputerName=%strComputername%>sysprep2.infECHO ProductKey="%strProduct%">>sysprep2.infCOPY /b sysprep1.inf + sysprep2.inf + sysprep3.inf sysprep.infECHO [UserData] section completed... Use more pieces if ProductKey goes in another section. Link to comment Share on other sites More sharing options...
Martin Zugec Posted July 29, 2005 Share Posted July 29, 2005 Remove @Echo Off and add Pause command, so you will see where exactly is the problem. You can also try to hardcode path to getmac... Link to comment Share on other sites More sharing options...
Sonic Posted July 29, 2005 Share Posted July 29, 2005 after @echo off insert cd /d "%~dp0" The batch search all external program in the folder of the batch ...Goodbye. Link to comment Share on other sites More sharing options...
Thinkster Posted July 29, 2005 Author Share Posted July 29, 2005 Don't use Fedit at all: Simple divide the sysprep.inf in 2 parts at [userData] sectionsysprep1.infsysprep3.infECHO Now editing Sysprep.inf ...ECHO ComputerName=%strComputername%>sysprep2.infECHO ProductKey="%strProduct%">>sysprep2.infCOPY /b sysprep1.inf + sysprep2.inf + sysprep3.inf sysprep.infECHO [UserData] section completed... Use more pieces if ProductKey goes in another section.<{POST_SNAPBACK}>Yes, that seems to work!! I made the following changes though:ECHO ComputerName=%strComputername%>>userdata.infECHO ProductKey="%strProduct%">>userdata.infCOPY /b sysprep1.inf + userdata.inf sysprep.infMy sysprep1.inf contains everything but the [user Data] sectionmy 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\wbemCD \CD Sysprepfixed that issue...Thanks again to all those who helped on this!! Link to comment Share on other sites More sharing options...
djbe Posted August 3, 2005 Share Posted August 3, 2005 (edited) uhm, fedit CAN handle quotes just use something like this:fedit -add -f "some file" -l "a line with some \"quotes\" here" Edited August 3, 2005 by djbe Link to comment Share on other sites More sharing options...
Viper999 Posted August 14, 2005 Share Posted August 14, 2005 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 More sharing options...
Nilfred Posted August 18, 2005 Share Posted August 18, 2005 @Viper999:WTF compname.exe is?Try MAC adresses first, then replace all instances of GetMac with compname.exeHere 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 More sharing options...
permster Posted July 15, 2006 Share Posted July 15, 2006 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 More sharing options...
Bilou_Gateux Posted July 16, 2006 Share Posted July 16, 2006 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. share your knowledge! Link to comment Share on other sites More sharing options...
cydin Posted September 22, 2006 Share Posted September 22, 2006 I have the same problem to assign computer names which I need for joining domains. Now, where do I run this batch file and where do I put it? Link to comment Share on other sites More sharing options...
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