Skip to content

Commit

Permalink
okay, fixed service stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
TsunayoshiSawada committed Oct 27, 2019
1 parent 7d22b49 commit 292ee35
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
28 changes: 1 addition & 27 deletions restart.bat
Original file line number Diff line number Diff line change
@@ -1,27 +1 @@
@echo off

:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>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"
:--------------------------------------
net stop SaitamaRobot && net start SaitamaRobot
start cmd.exe /c start_service.bat
2 changes: 1 addition & 1 deletion start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ IF "%ERRORLEVEL%" == "0" (
py -3.6 -m tg_bot
) ELSE (
py -m tg_bot
)
)
28 changes: 28 additions & 0 deletions start_service.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@echo off

:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>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"
:--------------------------------------
net stop SaitamaRobot
net start SaitamaRobot

0 comments on commit 292ee35

Please sign in to comment.