Join Forum | Login | Today's Posts | Tutorials | Windows 10 Forum | Windows 8 Forum

 Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

# Windows 7: Help me with the syntax of this bat file that changes my ip address

 11 Sep 2015 #11 Pyprohly Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan 620 posts Sydney, NSW @GokAy I used the random number function SS64 used here. They use a function like, Code: `f(min, max) = floor(randint(0, 32767) * max / 32768) + min` I tested with different max and min values and I found that with some pairs of max and min the function returns numbers greater than the max. Though their example of f(0,500) seems to work OK . For example, try f(50, 100) Code: `set /a rand=%RANDOM%*100/32768+50` It tends to return numbers greater than 100 fairly often. The same thing happens with your function, Gokay, of, Code: `f(min,max) = randint(0, 32767) % 244 + 10` it occasionally generates numbers greater than the given max, 244. Again, this is more apparent if you pass in numbers more closer to each other, e.g. f(50, 100). Here are the corrected functions, Code: `f(min, max) = floor(randint(0, 36727) * (max-min+1) / 32767) + min` and Code: `f(min, max) = rand(0, 36727) % (max-min+1) + min` which translates into Batch as Code: `set /a rand=%RANDOM% * (%MAX%-%MIN%+1) / 32768 + %MIN%` and Code: `set /a rand=%RANDOM% %% (%MAX%-%MIN%+1) / 32768 + %MIN%` respectively. I guess I'll be using the above line to retrieve random numbers when in Batch from now on.    Quote: Originally Posted by GokAy [...] (single % before 244 instead of %% in script) Other way 'round. Double percent in script, single percent on command line.    Quote: Originally Posted by Delta 7 This is the original script netsh interface ip set address name="Wireless Network Connection" static 192.168.1.64 255.255.255.0 192.168.1.254; its supposed to change any variable inbetween each dot within each address For example? My System Specs
 .