Windows 7 Forums
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

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan

@GokAy I used the random number function SS64 used here. They use a function like,
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)
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,
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,
f(min, max) = floor(randint(0, 36727) * (max-min+1) / 32767) + min
f(min, max) = rand(0, 36727) % (max-min+1) + min
which translates into Batch as
set /a rand=%RANDOM% * (%MAX%-%MIN%+1) / 32768 + %MIN%
set /a rand=%RANDOM% %% (%MAX%-%MIN%+1) / 32768 + %MIN%

I guess I'll be using the above line to retrieve random numbers when in Batch from now on.

Quote   Quote: Originally Posted by GokAy View Post
[...] (single % before 244 instead of %% in script)
Other way 'round. Double percent in script, single percent on command line.

Quote   Quote: Originally Posted by Delta 7 View Post
This is the original script

netsh interface ip set address name="Wireless Network Connection" static;

its supposed to change any variable inbetween each dot within each address
For example?

My System SpecsSystem Spec

 Help me with the syntax of this bat file that changes my ip address

Thread Tools

Similar help and support threads
Thread Forum
Get the Full Process path from the prefetch file.(Offset Address)
I am in an attempt of listing some details from the Windows Prefetch file such Filename, FileCreatedTime, FileModifiedTime,File Size, Process Name, Process Path,Run Counter & Last Run time. Though there are many tools like Nirsoft WinPrefetchViewer and couple of more available. I thought of...
General Discussion
Copy file address after doing a file search in windows explorer
Hi All I have a rather large file system with lots of folders & subfolders. When I want to save previously on Xp operating system I'd search in explorer open the folder I want then copy the address (e.g c:\customer records\client name\job address). In windows 7, when I copy the folder address i...
General Discussion
Batch file syntax file
I'm trying to create a batch file that will copy some excel files from my usb drive to my c: . this is what I'm putting in the command line. e: cd excelbak\exlbak13 copy *.* c:\program files\microsoft office\office12\excel comment I get is invalid sytanx in command line...I'm thinking that...
Performance & Maintenance
host file/ loopback address broken cannot update AV/loginto WLM
Hi guys, this has been going for a couple of days now, I cannot loginto windows live messenger and cannot update my avira free edition anti virus So I tried updating my AV one night and found that I could not - kept coming up with an error... I could browse the web and torrent etc and so I...
Network & Sharing
Proper exact address syntax?
If I would like to point one PC at the exact address of another PC over the internet, NOT a local area network, how would it look? http: (example, don't try it, probably some creep's ip, lol!) I have tried googling syntax, address etc. but I am just lost, and...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 18:44.
Twitter Facebook Google+