Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM THIS IS TO BE USED IN A .CMD FILE
- @echo off
- call
- echo === Nahimic Service Fix for Sonic Studio 3 ===
- echo:
- REM First thing to do is to check for admin privileges availability
- goto check_permissions
- REM Check admin privileges (services can be stopped only with admin user)
- :check_permissions
- echo Checking for admin privileges...
- net session >nul 2>&1
- if %errorLevel% equ 0 (
- echo Success.
- goto verify_not_running
- ) else (
- echo Error. You must execute this script with admin privileges.
- pause
- exit /b 0 REM Force successful exit
- )
- REM Service status check (generic)
- :verify_not_running
- call
- echo:
- echo Checking service status...
- sc query "NahimicService" | findstr RUNNING >nul 2>&1
- REM If there are no errors it means that the service is already running. If there are errors it means it is not running.
- if %errorlevel% equ 0 (
- goto stop
- ) else (
- goto start
- )
- REM Service start
- :start
- call
- echo Service is not running. Starting NahimicService...
- sc start "NahimicService" >nul 2>&1
- if %errorlevel% equ 0 (
- goto verify_running
- ) else (
- goto error
- )
- REM Service stop
- :stop
- call
- echo Service is already running. Stopping NahimicService...
- sc stop "NahimicService" >nul 2>&1
- if %errorlevel% gtr 0 (
- goto error
- ) else (
- echo The service is being stopped. Please wait 5 seconds...
- REM A few seconds are needed in order for the service to be stopped. Ping workaround is useful to avoid the user messing with the script
- ping 127.0.0.1 -n 5 > nul
- goto verify_not_running
- )
- REM Check service status after start
- :verify_running
- call
- echo:
- echo Checking service status...
- sc query "NahimicService" | findstr RUNNING >nul 2>&1
- if %errorlevel% gtr 0 (
- goto error
- ) else (
- echo Service successfully started!
- goto success
- )
- REM Error verbose - this part of the script will probably never be executed (but it is here just in case)
- :error
- echo Error. Check the service status manually and ensure you are executing this script with admin privileges.
- echo:
- pause
- exit /b 0
- REM Success verbose - print new line, pause the script, exit the script
- :success
- echo:
- pause
- exit /b 0
Add Comment
Please, Sign In to add comment