npocmaka / batch.scripts

batch script utils and examples by npocmaka -
https://www.linkedin.com/in/npocmaka/
MIT License
1.08k stars 873 forks source link

( I'm a beginner ) I need help with a program I want to write #40

Closed soilderscout44 closed 2 years ago

soilderscout44 commented 2 years ago

I want to write a batch script that will start a website if it isn't started and detect if it is closed and reopen it again, I'm not sure if this is possible but im really intrigued to find out so far I'm stuck on how to get it to loop as in constantly check if the website is open or if it is closed right now I'm going somewhere along the lines of this but I get stuck on trying to figure out how to loop it to where it will reopen the website if closed

@echo off
Color 09
Title Website Checker
Goto start

:start 
Taskkill /T "msedge.exe"
Cls
Echo press any key to launch website.com
Pause
Start www.website.com
Timeout /t 15
Pause
andry81 commented 2 years ago

It depends what you mean by "it started". If it means a browser application is running, then something like that is enough:

@echo off
:LOOP
start "" /B /WAIT msedge.exe "www.website.com"
goto LOOP

If it must rely on the site responce, then you should use scripts from inside of the browser. You could write a javascript script and use the tampermonkey browser extension to inject it while a site is opened to track a site behaviour.

selfish-sailfish commented 2 years ago

This sounds like a container solution type of problem.

On Thu, Jan 27, 2022 at 8:21 PM soilderscout44 @.***> wrote:

I want to write a batch script that will start a website if it isn't started and detect if it is closed and reopen it again, I'm not sure if this is possible but im really intrigued to find out

— Reply to this email directly, view it on GitHub https://github.com/npocmaka/batch.scripts/issues/40, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFDHQMR35G5YIZCKR7CDT3UYIKTJANCNFSM5M7XV5YA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Michael Tucker (360)947-6011 @.***