Thinkster Posted June 29, 2008 Share Posted June 29, 2008 My goal is to query the MAC of the PC's network card and then look it up in a simple text database file in the format of:MAC,PCName,ProductKey,Path on each line.Once it finds the MAC in the file 'mac.txt' it should Display the PC Name, Product Key and Path on the screen just for confirmation, then it should change the PC Name, and copy contents from the path specified to C:\ABR and finally run an .exe file in the C:\ABR folder.Here's a sample of proposed mac.txt:"00-E0-B8-80-59-06",PCLAB-01,CXXXT-988V6-GXXXX-8HP7R-H4KK3,%WINDIR%/Activation/PCLAB01"00-E0-B8-80-58-B6",PCLAB-02,W8HKH-4XXXX-HVRFD-GXXXX-2XXVG,%WINDIR%/Activation/PCLAB02"00-E0-B8-80-58-41",PCLAB-03,DXXXF-78W4P-V8CBY-TXXX9-QX6QW,%WINDIR%/Activation/PCLAB03"00-E0-B8-80-58-AF",PCLAB-04,RDM42-GK4BV-X72YB-RQXP3-RXDJJ,%WINDIR%/Activation/PCLAB04"00-E0-B8-80-57-15",PCLAB-05,TXQ6B-3XXXX-Y6RXP-YTGGW-QXXX3,%WINDIR%/Activation/PCLAB05"00-E0-B8-80-58-0B",PCLAB-06,XXXXP-XXX8W-MXXXX-H99R7-XXX9D,%WINDIR%/Activation/PCLAB06Here's my partial script that needs refining and the part to rename the PC and copy files...ECHO Determining Machine Name and Product Key...ECHO.ping -n 3 localhost> NULFor /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=%%cSet strPath=%%d) )Echo Computer Name should be: %strComputername%ping -n 2 localhost> NULEcho Product Key should be: %strProduct%ECHO.Echo Path to Activation files should be: %strPath%Any help would be appreciated! Link to comment Share on other sites More sharing options...
Thinkster Posted June 30, 2008 Author Share Posted June 30, 2008 Nevermind, I figured it out, I just had to think it through. But just in case this is usefull to anyone, here's the code:@echo off && Mode 80,25 && Color F2TITLE OEM ActivationECHO.ECHO Determining Machine Name and Product Key...ECHO.ping -n 3 localhost> NULFor /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) )ping -n 3 localhost> NULEcho Computer Name should be: %strComputername%ping -n 3 localhost> NULEcho Product Key should be: %strProduct%ping -n 3 localhost> NULEcho Path to Activation files should be: C:\Windows\Activation\%strComputername%Echo.ping -n 3 localhost> NULEcho Activating Windows...Echo.copy c:\windows\Activation\%strComputername%\*.* c:\Windows\Activation\ /ystart /wait C:\Windows\Activation\activation_restore.exe --silentECHO Windows should now be OEM Activated!Echo.ping -n 4 localhost> NULEXITOf course you need a lookup table file called mac.txt in the format:"00-E0-B8-80-59-06",PCLAB-01,CXXXT-988V6-GXXXX-8HP7R-H4KK3 " MAC ID ", PC Name , Product KeyAnd you should have a folder in Windows called 'activation' containing subfolders with each computer's name. These subfolders should contain the OEM activations files (backup-cert.xrm-ms, backup-key.txt) from the respective computer. The root folder (Activation) should have the 'activation_restore.exe' file. By the way, the activation routine here is specifically for Vista OEM edition. 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