Thanks for that, I've spent a lot of time on that site recently, along with Computer Hope it's where I've found the most information.
I've been over everything and solved all the problems except for one which I'll get to in a minute.
I can toggle between 2 batch files with the following:
if exist prog-running.txt goto running
rem prog is not running
start /D "C:\Batch Files\AHKOSK ON-OFF" AHKOSK_ON.bat
rem prog is already running
start /D "C:\Batch Files\AHKOSK ON-OFF" AHKOSK_OFF.bat
I ran your script from reply 4, on XP it runs as is, on 7 I had to modify it.
Besides the differences in NIC details I cannot get the "" setting to run on 7, I have to change it to /D, then it runs perfectly.
If I use "" I either get an error message or it opens an Explorer window to the relevant folder.
So the file on 7 reads thus:
rem Check if our flag file exists and act accordingly
if exist internet_is_on.txt goto running
rem Turning Internet items ON
start /D "C:\Program Files (x86)\D4" D4.exe
start /D "C:\Program Files (x86)\Sandboxie" SbieCtrl.exe
start /D "C:\Program Files (x86)\PeerBlock" peerblock.exe
netsh interface set interface "Router Connection" ENABLED
rem Internet is ON, turn it all OFF now
taskkill /F /IM peerblock.exe
taskkill /F /IM SbieCtrl.exe
taskkill /F /IM D4.exe
netsh interface set interface "Router Connection" DISABLED
The problem is that just like my original Internet ON-OFF files it leaves the icons in the system tray after the programs shut down on both OS'.
But, I have two files which toggle a single program:
taskkill /f /im ahk_osk.exe || start /D "C:\Program Files\AHKOSK" ahk_osk.exe
This leaves the icon in place.
tasklist /fi "ImageName eq ahk_osk.exe" | find /i "ahk_osk.exe" && taskkill /fi "ImageName eq ahk_osk.exe" || start /D "C:\Program Files\AHKOSK" ahk_osk.exe
This removes the icon.
My question is whether it is possible to incorporate something from this second file, or anything else for that matter, into your script from reply 4 so that it will automatically remove the icons when the programs are closed?