Sign in to follow this  
Followers 0
danishmo

Random by seconds?

4 posts in this topic

I made a program to generate a random number for our LAN partys. It would set the IP to 10.10.10.<random>. I was wondering if it was possible to make the random number the current second the time is. That way it would help prevent IP conflicts.

Also, is there a way to wait for a certain program to load? WinWaitActive() wont cut it. I run command prompt, but some people have different drive names so instead of "C:\WINDOWS\system32\cmd.exe" comming up they might have "I:\WINDOWS\system32\cmd.exe" or something as the title. Can I either use a variable for the drive or have it wait for cmd.exe to load?

Thanks in advance for the help!

Share this post


Link to post
Share on other sites



Ok thanks!

I figured out how to wait for command prompt to open. All I am doing is having it type "ipconfig" so it shows what the IP is incase of IP conflicts.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I was wondering if it was possible to make the random number the current second the time is.

I don't think setting it to the current second would be very random. Also, if the person ends up getting a xxx.xxx.xxx.0 or xxx.xxx.xxx.1 IP it could result in some errors, as .0 is reserved for broadcasts and .1 is usually the IP address for the gateway. You could try using the second plus a number so that you dont get that problem, like $ip = "10.10.10." & (@SEC + 10)

Edit: Your probably better off using a random number instead of the second since theres only 60 seconds, yet there is around 250 different values for the ip. You could have it ping the ip after you randomize it to see if that one exists.

So try

Do
$ip = "10.10.10." & Random(2, 254, 1)
$relpy = Ping($ip)
Until $reply > 0
Edited by BPBNA

Share this post


Link to post
Share on other sites

awaiting the barage of advice....

:D Slow day, I guess...

@danishmo: don't run cmd.exe just to send it keystrokes. If you need the output of a command, use StdoutRead.

Also, cmd.exe is unneccessary if all you want is the current IP. Use the @IPAddress1 macro.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0