Recommended Posts

JoaoCampos 0

JoaoCampos 0

;~ Get some var info from config file$server=IniRead("config.ini","General","Server","none")$showurl=IniRead("config.ini","General","Show","none")$iepath="c:\Program Files\Internet Explorer\iexplore.exe"$checkiemode=RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings','GlobalUserOffline');~ Loop check for server and execute different commands for each stateWhile1$servertest=Ping($server,250);~ If server ping responds OK and, in the Registry Internet state is set to offline...If$servertest&$checkiemode=1Then;;~ Set Internet explorer to Online ModeRegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","GlobalUserOffline","REG_DWORD","0");~ Run taskkill all Iexplorer process'sRun("TASKKILL /F /IM iexplore.exe");~ Wait 1000 msSleep(1000);~ Start the show againShellExecute($showurl);~ If server ping dont responds and, in the Registry Internet state is set to Online...ElseIf$servertest&$checkiemode=0Then;;~ Set Internet explorer to Offline ModeRegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","GlobalUserOffline","REG_DWORD","1");~ Run taskkill all Iexplorer process'sRun("TASKKILL /F /IM iexplore.exe");~ Wait 1000 msSleep(1000);~ Start the show againShellExecute($showurl)ElseEndIf;~ Wait 5000 ms until next loopSleep(5000)WEnd

My ini file is:

[General]

Server=prtn.zapto.org

Show=http://prtn.zapto.org/web/player

The idea is:

It executes a ping command,

if the ping commands responds ok AND in the registery we have offline mode, it sets Internet to onlinemode, Kills all iexplore.exe tasks, make some delay, and executes again iexplore with url running the page in online mode;

if the ping commands do not responds AND in the registery we have online mode, it sets Internet to offlinemode, Kills all iexplore.exe tasks, make some delay, and executes again iexplore with url running the page in offline mode from cache.

My problem is... i dont know how to tell in the elseif "ElseIf $servertest "dont responds" & $checkiemode=0 Then;".... if ping do not responds and mode is online.

Share this post

Link to post

Share on other sites

smashly 11

smashly 11

ProcessExist() , ProcessClose , ProcessWaitClose .. these functions can do away with the Run Task Kill and extra Sleep() your adding.

;~ Get some var info from config file$server=IniRead("config.ini","General","Server","")$showurl=IniRead("config.ini","General","Show","")$iepath=@ProgramFilesDir&"\Internet Explorer\iexplore.exe";~ Loop check for server and execute different commands for each stateWhile1$servertest=Ping($server,3000)$checkiemode=RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings','GlobalUserOffline');~ If server ping responds OK and, in the Registry Internet state is set to offline...If$servertest<>0And$checkiemode=1Then$rw=RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","GlobalUserOffline","REG_DWORD","0")IfProcessExists('iexplore.exe')Then; See if IE is running before trying to close it.ProcessClose('iexplore.exe'); This replaces Task Kill via cmd windowProcessWaitClose('iexplore.exe',1000); Wait upto 1000 ms for process to close, If it closes quicker then 1000ms then script continues on EndIfShellExecute($showurl)ElseIf$servertest=0And$checkiemode=0ThenRegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","GlobalUserOffline","REG_DWORD","1")IfProcessExists('iexplore.exe')Then; See if IE is running before trying to close it.ProcessClose('iexplore.exe'); This replaces Task Kill via cmd windowProcessWaitClose('iexplorer.exe',1000); Wait upto 1000 ms for process to close, If it closes quicker then 1000ms then script continues on EndIfShellExecute($showurl)EndIfSleep(5000)WEnd

Maybe add a hotkey to exit the script as well

Add a pop up input box to a hotkey as well , so you can change the server address and url when felt like.

the list just goes on..lol

Good luck and

Cheers.

Edited April 11, 2007 by smashly

Share this post

Link to post

Share on other sites

JoaoCampos 0

JoaoCampos 0

ProcessExist() , ProcessClose , ProcessWaitClose .. these functions can do away with the Run Task Kill and extra Sleep() your adding.

;~ Get some var info from config file$server=IniRead("config.ini","General","Server","")$showurl=IniRead("config.ini","General","Show","")$iepath=@ProgramFilesDir&"\Internet Explorer\iexplore.exe";~ Loop check for server and execute different commands for each stateWhile1$servertest=Ping($server,3000)$checkiemode=RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings','GlobalUserOffline');~ If server ping responds OK and, in the Registry Internet state is set to offline...If$servertest<>0And$checkiemode=1Then$rw=RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","GlobalUserOffline","REG_DWORD","0")IfProcessExists('iexplore.exe')Then; See if IE is running before trying to close it.ProcessClose('iexplore.exe'); This replaces Task Kill via cmd windowProcessWaitClose('iexplore.exe',1000); Wait upto 1000 ms for process to close, If it closes quicker then 1000ms then script continues on EndIfShellExecute($showurl)ElseIf$servertest=0And$checkiemode=0ThenRegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","GlobalUserOffline","REG_DWORD","1")IfProcessExists('iexplore.exe')Then; See if IE is running before trying to close it.ProcessClose('iexplore.exe'); This replaces Task Kill via cmd windowProcessWaitClose('iexplorer.exe',1000); Wait upto 1000 ms for process to close, If it closes quicker then 1000ms then script continues on EndIfShellExecute($showurl)EndIfSleep(5000)WEnd

Maybe add a hotkey to exit the script as well

Add a pop up input box to a hotkey as well , so you can change the server address and url when felt like.

the list just goes on..lol

Good luck and

Cheers.

Ive tested it before and the problem with processclose is that if i have more than one process called iexplore.exe, it only closes one of them.