不使用15分钟后运行程序

时间:2022-04-12 05:00:01

I am finishing building Google Earth for my hotel that contains different activities, shopping, and dining ideas. The owner wants it in a certain way, however, I am not a programmer and he does not want to pay for one. So I am learning as I go. I posted before about something I was wondering. ( Closing and Opening a .exe with a batch file. Upon closing the program asks to save or not)

我正在为我的酒店完成构建Google地球,其中包含不同的活动,购物和餐饮创意。所有者以某种方式想要它,但是,我不是程序员而且他不想支付一个。所以我正在学习。我之前发过关于我想知道的事情。 (关闭并打开带有批处理文件的.exe。关闭程序时要求保存与否)

My next question is; is it possible to force close the program and open in up if the program was not used for 15 minutes? Could some one point me into the right direction. Thank you.

我的下一个问题是;是否有可能强制关闭程序并在程序未使用15分钟时打开?有人可以指出我正确的方向。谢谢。

1 个解决方案

#1


You'll need qprocess or tasklist commands and there's a small chance to not have neither of these (you should check it)

你需要qprocess或tasklist命令,并且很可能没有这些命令(你应该检查它)

here's an example script

这是一个示例脚本

@echo off
rem -- checking if the machine is x32 or x64
rem -- google earth clinet is x32
if defined ProgramFiles(x86) (
  set "ge=C:\Program Files (x86)\Google\Google Earth\client\googleearth.exe"
) else (
   set "ge=C:\Program Files\Google\Google Earth\client\googleearth.exe"
)

rem -- better approach is to check the registry bu here I'll use default folders

:repeat
tasklist | find /i "googleearth" && (
   rem -- program is running
   rem -- we need to wait and repeat
   rem -- waiting 15 minutes
   ping 192.0.2.1 -n 1 -w 90000 >nul 2>nul
   goto :repeat
) || (
  rem -- program is not running 
  rem -- we need to start it again

  start "" "%ge%" 

)

#1


You'll need qprocess or tasklist commands and there's a small chance to not have neither of these (you should check it)

你需要qprocess或tasklist命令,并且很可能没有这些命令(你应该检查它)

here's an example script

这是一个示例脚本

@echo off
rem -- checking if the machine is x32 or x64
rem -- google earth clinet is x32
if defined ProgramFiles(x86) (
  set "ge=C:\Program Files (x86)\Google\Google Earth\client\googleearth.exe"
) else (
   set "ge=C:\Program Files\Google\Google Earth\client\googleearth.exe"
)

rem -- better approach is to check the registry bu here I'll use default folders

:repeat
tasklist | find /i "googleearth" && (
   rem -- program is running
   rem -- we need to wait and repeat
   rem -- waiting 15 minutes
   ping 192.0.2.1 -n 1 -w 90000 >nul 2>nul
   goto :repeat
) || (
  rem -- program is not running 
  rem -- we need to start it again

  start "" "%ge%" 

)