Go Back   Novahq.net Forum > Computers > Web design and Programming
FAQ Community Calendar Today's Posts Search

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-07-2005, 09:19 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,933

Help please...

Can anyone help me here? What I want to do:

Get a program that will ping a website like google or yahoo or something and if it cannot ping it for 5 minutes run a bat file to shutdown & restart the computer?

shutdown /r /t 20 /m \\[name] /c "Computer is shutting down" /f


For some reason if my cable connection goes down my computer will not automatically renew (since it's a static ip) & it looses the dns servers which cause it to think it's connected, but not actually be connected . AN easy way to fix it is to repair it from network connections but that seems more complcated for a script then to just ping somewhere and run a script if it fails..

Any programmers wanna have a go at this?
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #2  
Old 12-07-2005, 09:44 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,933

Well I found a ping script that will ping a host, but I need something that will run it every 5 minutes, even if I am logged off the computer, so it should be able to be installed as a Local System Service.. Anyone got any suggestions:


ping-reboot.vbs:

Code:
strTarget = "google.com"

Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("ping -n 4 -w 1000 " & strTarget)
strPingResults = LCase(objExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
'WScript.Echo strTarget & " responded to ping."
  Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" & strTarget & "\root\cimv2")
  Set colCompSystems = objWMIService.ExecQuery("SELECT * FROM " & _
"Win32_ComputerSystem")
  For Each objCompSystem In colCompSystems
    WScript.Echo "Host Name: " & LCase(objCompSystem.Name)
  Next
Else

'WScript.Echo strTarget & " did not respond to ping."

Set objShell2 = CreateObject("WScript.Shell")
Set objExec = objShell2.Exec("shutdown /r /t 30 /f")

End If
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #3  
Old 12-07-2005, 10:09 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,933

Ok never mind I figured out how to make the task scheduler in windows run that script every 10 minutes . That should help keep the server going.. should do more research before I ask but there is one prob..

There is an error in the code somewhere.. it works ok, but about 3 minutes after I run it I get an error on line 8, char 3 with the GetObject("winmgmts:" not being an object or something? Anyone know? I don't know vb yet
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #4  
Old 12-07-2005, 06:08 PM
VooDoo- is offline VooDoo-
VooDoo-'s Avatar
Registered User

Join Date: Jan 2004
Location: Florida
Posts: 2,896

you lost me in your first sentence
__________________
Reply With Quote
  #5  
Old 12-07-2005, 06:11 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,933

weird. i didn't know a single line of vb before today
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #6  
Old 12-07-2005, 06:16 PM
Hellfighter is offline Hellfighter
Hellfighter's Avatar
Chief ADFP

Join Date: Jun 2002
Location: San Jose Calif 95111
Posts: 21,144

Send a message via ICQ to Hellfighter
i am clueless i say try it without the ts or s in it, it could be wrong wording like a miscoding double check "winmgmts:"

only a guess
__________________
* altnews sources [getmo & others news] not found main FNN: realrawnews.com
*Discord: Unknown77#7121
Playing now days: EA Games> swtor [star wars old republic]
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 07:01 AM.




Powered by vBulletin®