Hi all
I'm currently working at a netlogon script. I came as far as you can see below (the comments are in german, so, ignore them );
@echo off
cls
REM Scripted by B.Grob / Cropmark AG
REM ** Variable ipadress deklarieren **
for /f "Tokens=2 Delims=[] skip=1" %%i in ('ping -n 1 %computername%') do set IPAdress=%%i
REM ** Bestimmen des Subnetz **
If %IpAdress% LEQ 192.168.0.0 Goto unbekannt
If %IpAdress% LEQ 192.168.100.9 Goto 100
If %IpAdress% LEQ 192.168.100.99 Goto 100
If %IpAdress% LEQ 192.168.100.255 Goto 100
If %IpAdress% LEQ 192.168.200.9 Goto 200
If %IpAdress% LEQ 192.168.200.99 Goto 200
If %IpAdress% LEQ 192.168.200.255 Goto 200
If %IpAdress% LEQ 192.168.222.9 Goto 222
If %IpAdress% LEQ 192.168.222.99 Goto 222
If %IpAdress% LEQ 192.168.222.255 Goto 222
If %IPAdress% GEQ 192.168.255.0 Goto unbekannt
GOTO ENDE
REM ** Bei Welchem Subnetz was machen **
REM ** Subnet 192.168.100.0 **
:100
net use * /delete
y
y
y
net use p: \\server8\server8
goto ende
REM ** Subnet 192.168.200.0 **
:200
net use * /delete
y
y
y
net use p: \\server6\server6
goto ende
REM ** Subnet 192.168.222.0 **
:222
net use * /delete
y
y
y
net use p: \\server4\server4
goto ende
REM ** Subnet grösser oder kleiner als der definierte Bereich **
:unbekannt
shutdown /l
Goto ende
:ende
Now, i have two questions;
1. To define in which subnet the client is, I had to check three times (1 for 1-digit ips, 1 for 2-digit ips, 1 for 3-digit ips). I really belive this isn't the nice way to programm a script, but I don't know how to do it correctly. I tryed it with 192.168.100.* or 192.168.100.???, but neither of them worked.
2. As you can see, I delete the currently mapped networkshares in a really ugly way, but didn't found a better way yet. The three y's are for the confirmation that is needed. There must be a better way for this (or better, I hope there is a better way), didn't found out which one it is untill now.
I hope somone can help..
I'm currently working at a netlogon script. I came as far as you can see below (the comments are in german, so, ignore them );
@echo off
cls
REM Scripted by B.Grob / Cropmark AG
REM ** Variable ipadress deklarieren **
for /f "Tokens=2 Delims=[] skip=1" %%i in ('ping -n 1 %computername%') do set IPAdress=%%i
REM ** Bestimmen des Subnetz **
If %IpAdress% LEQ 192.168.0.0 Goto unbekannt
If %IpAdress% LEQ 192.168.100.9 Goto 100
If %IpAdress% LEQ 192.168.100.99 Goto 100
If %IpAdress% LEQ 192.168.100.255 Goto 100
If %IpAdress% LEQ 192.168.200.9 Goto 200
If %IpAdress% LEQ 192.168.200.99 Goto 200
If %IpAdress% LEQ 192.168.200.255 Goto 200
If %IpAdress% LEQ 192.168.222.9 Goto 222
If %IpAdress% LEQ 192.168.222.99 Goto 222
If %IpAdress% LEQ 192.168.222.255 Goto 222
If %IPAdress% GEQ 192.168.255.0 Goto unbekannt
GOTO ENDE
REM ** Bei Welchem Subnetz was machen **
REM ** Subnet 192.168.100.0 **
:100
net use * /delete
y
y
y
net use p: \\server8\server8
goto ende
REM ** Subnet 192.168.200.0 **
:200
net use * /delete
y
y
y
net use p: \\server6\server6
goto ende
REM ** Subnet 192.168.222.0 **
:222
net use * /delete
y
y
y
net use p: \\server4\server4
goto ende
REM ** Subnet grösser oder kleiner als der definierte Bereich **
:unbekannt
shutdown /l
Goto ende
:ende
Now, i have two questions;
1. To define in which subnet the client is, I had to check three times (1 for 1-digit ips, 1 for 2-digit ips, 1 for 3-digit ips). I really belive this isn't the nice way to programm a script, but I don't know how to do it correctly. I tryed it with 192.168.100.* or 192.168.100.???, but neither of them worked.
2. As you can see, I delete the currently mapped networkshares in a really ugly way, but didn't found a better way yet. The three y's are for the confirmation that is needed. There must be a better way for this (or better, I hope there is a better way), didn't found out which one it is untill now.
I hope somone can help..