Hotlink sensors are sometimes unavailable. To fix this, I restart the IOTLink service and the sensors start working again. This happens quite often and I was thinking about automatically restarting the IOTLink service. The IOTLink service itself works and standard sensors do not fail. It is user sensors that fail, for example Process Monitor. I created a batnik and run it to restart the IOTLink service, but I ran into a problem. Elevated permissions are required to run the batnik.
In c:\ProgramData\IOTLink\Addons\ProcessMonitor\apps\Games.yaml I added the following
processes:
- ACValhalla.exe
- DOOMEternalx64vk.exe
- HorizonZeroDawn.exe
- HaloInfinite.exe
- RAGE2.exe
- GoW.exe
- MetroExodus.exe
windows:
classnames:
configs:
enabled: true
discoverable: true
advancedMode: false
displayName: Games
cacheable: true
grouped: true
compareType: 0
interval: 10
I wrote a batnik that restarts the IOTLink service, but there is a problem, the batnik does not start, since elevated rights and UAC bypass are required. I found an option and wrote it like this, the option is below
This batnik cannot start because administrator rights are required
@echo off
net stop IOTLink
rem
net start IOTLink
This batnik runs with administrator rights via IOTLink, but does not bypass UAC, you have to turn off UAC.
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params= %*
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
@echo off
net stop IOTLink
rem
net start IOTLink
Tried using runas, also doesn’t help
runas /user:user "c:\scripts\iotlink_reboot.bat"
Running the script via IOTLink looks like this
service: mqtt.publish
data:
topic: iotlink/workgroup/livingroom/commands/run
payload: >-
{ "command": "C:\\scripts\\iotlink_reboot.bat", "path": "C:\\scripts",
"user": "", "visible": false, "fallback": true }