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
Pyprohly

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,
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   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 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 SpecsSystem Spec
.
Reply

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




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
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
How to make File Explorer display full address of files in search
I have done a search and file explorer returns some results. You can see the locations of each file are chopped off. But there is no grid splitter allowing me to expand the filename column. How can I view the whole address of the files in Search results?
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:293.86.45.567.123:192.168.0.199 (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:12.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App