|I'm trying to write a script to open a shared folder on a workstation that has the same first two octets of the IP address. This way users in different locations find a workstation with the first two octets the same as their own. (The last two octets --0.100-- are fixed on the local workstation.) This is because, for us, the first two octets (or really just the second) indicates the physical location. The idea is that we can load large files to this folder overnight, and then users could quickly open these files during business hours from the local folder.|
I've put together the script below, but for some reason, it only works on the computer I wrote it on. On other computers it fails at the last command, doing nothing. I've also tried this with the command iexplore.exe instead of explorer.exe, and it just opens a web browswer to the homepage. However, even this works on the original computer.
This will need to work on different computers, including XP, Win7, and Vista. Any help in finding out what I can fix would be greatly appreciated.
ipconfig | find "IP Address" > ~ip1.txt
for /f "tokens=1-2 delims=:" %%i in (~ip1.txt) do echo %%j > ~ip2.txt
for /f "tokens=1-3 delims=." %%i in (~ip2.txt) do echo %%i.%%j.0.100 > ~ip3.txt
set /p var=<~ip3.txt
start explorer.exe \\!var!\open