Jump to content

Random by seconds?


Recommended Posts

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!

Link to comment
Share on other sites

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
Link to comment
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]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...