MrChrHD

Nahimic Service Fix for Sonic Studio 3 (W7+)

Jan 19th, 2022 (edited)
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. REM THIS IS TO BE USED IN A .CMD FILE
  2. @echo off
  3. call
  4.  
  5. echo === Nahimic Service Fix for Sonic Studio 3 ===
  6. echo:
  7.  
  8. REM First thing to do is to check for admin privileges availability
  9. goto check_permissions
  10.  
  11. REM Check admin privileges (services can be stopped only with admin user)
  12. :check_permissions
  13.     echo Checking for admin privileges...
  14.  
  15.     net session >nul 2>&1
  16.     if %errorLevel% equ 0 (
  17.         echo Success.
  18.         goto verify_not_running
  19.     ) else (
  20.         echo Error. You must execute this script with admin privileges.
  21.         pause
  22.         exit /b 0 REM Force successful exit
  23.     )
  24.  
  25. REM Service status check (generic)
  26. :verify_not_running
  27.     call
  28.     echo:
  29.     echo Checking service status...
  30.     sc query "NahimicService" | findstr RUNNING >nul 2>&1
  31.     REM If there are no errors it means that the service is already running. If there are errors it means it is not running.
  32.     if %errorlevel% equ 0 (
  33.         goto stop
  34.     ) else (
  35.         goto start
  36.     )
  37.  
  38. REM Service start
  39. :start
  40.     call
  41.     echo Service is not running. Starting NahimicService...
  42.     sc start "NahimicService" >nul 2>&1
  43.     if %errorlevel% equ 0 (
  44.         goto verify_running
  45.     ) else (
  46.         goto error
  47.     )
  48.  
  49. REM Service stop
  50. :stop
  51.     call
  52.     echo Service is already running. Stopping NahimicService...
  53.     sc stop "NahimicService" >nul 2>&1
  54.     if %errorlevel% gtr 0 (
  55.         goto error
  56.     ) else (
  57.         echo The service is being stopped. Please wait 5 seconds...
  58.         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
  59.         ping 127.0.0.1 -n 5 > nul
  60.         goto verify_not_running
  61.     )
  62.  
  63. REM Check service status after start
  64. :verify_running
  65.     call
  66.     echo:
  67.     echo Checking service status...
  68.     sc query "NahimicService" | findstr RUNNING >nul 2>&1
  69.     if %errorlevel% gtr 0 (
  70.         goto error
  71.     ) else (
  72.         echo Service successfully started!
  73.         goto success
  74.     )
  75.  
  76. REM Error verbose - this part of the script will probably never be executed (but it is here just in case)
  77. :error
  78.     echo Error. Check the service status manually and ensure you are executing this script with admin privileges.
  79.     echo:
  80.     pause
  81.     exit /b 0
  82.  
  83. REM Success verbose - print new line, pause the script, exit the script
  84. :success
  85.     echo:
  86.     pause
  87.     exit /b 0
Add Comment
Please, Sign In to add comment