Newbie stuck on some variables, substrings etc
Posted: 11 May 2011 08:23
Hi guys,
I'm trying to write a batch script for windows XP. It needs to call ipconfig and build an IP address from the (192.168.XXX.30) XXX part of the address and supplanting it into a template. Then runs some fun stuff from a network shared folder.
At the moment I can't seem to get the result from ipconfig in to my variable, would be even better if I could get the substring from it in 1 line. When I try to echo the contents it just prints out _var:~25,-4
Any ideas? Thanks in advance
I'm trying to write a batch script for windows XP. It needs to call ipconfig and build an IP address from the (192.168.XXX.30) XXX part of the address and supplanting it into a template. Then runs some fun stuff from a network shared folder.
Code: Select all
SET _var=ipconfig |FIND "192.168"
SET _var=%_var:~25,-4%
net use z: \\192.168.%_var%.30\test_folder
... Do stuff
net use z: \DELETE
ECHO "Tasks completed"
PAUSE
At the moment I can't seem to get the result from ipconfig in to my variable, would be even better if I could get the substring from it in 1 line. When I try to echo the contents it just prints out _var:~25,-4
Any ideas? Thanks in advance