Basically here is the solution I'm looking for.
I want to be able to have Windows 7 detect when it doesn't get an IP from DHCP and run a script.
So I think I can use Task Scheduler to do this but need some help and I have a semi written script that doesn't seem to be working but maybe someone on here can help.
Basically what I need it to do is once the task scheduler detects it doesn't have an IP from DHCP and gets a 169.x.x.x IP address the script runs and then changes to a static IP, then telnet into the modem and run the reset command then then change back to DHCP and renew the IP.

Here is what I have so far but it keeps getting stuck when it goes to to the modem and maybe because I'm opening something twice because 2 CMD black boxes come up and when it logs into the modem it doesn't work right. If I run the restart modem script by itself it works fine just not with all this other stuff attached to it.
Set obj = CreateObject("WScript.Shell")
obj.run"cmd"
WScript.Sleep 500

obj.SendKeys"telnet 192.168.100.1"
obj.SendKeys("{Enter}")
WScript.Sleep 500

obj.SendKeys"root" 'telnet username
obj.SendKeys("{Enter}")
WScript.Sleep 500

obj.SendKeys"root" 'telnet password
obj.SendKeys("{Enter}")
obj.SendKeys"reset"
obj.SendKeys("{Enter}")
Wscript.Sleep 500


Dim oShell : Set oShell = CreateObject("WScript.Shell")

' Kill telnet and cmd '
oShell.Run "taskkill /im telnet.exe", , True
oShell.Run "taskkill /im cmd.exe", , True
Wscript.Sleep 500

So here is the script that restarts the modem and works just fine if I run it. But the problem is that if the computer can't get an IP then this script will fail because it can't telnet to 192.168.100.1 so it needs to change the IP to a static IP of 192.168.100.11 subnet 255.255.255.0 gateway 192.168.100.1 in order for it to be able to telnet.
Once it has static IP it can then run the above part.
Then when it's done resetting the modem it should then go back to DHCP.

Hope someone can help me.
Thanks
Brad