Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- @rem Checking & Prompting for run as administrator
- @rem --------------------------------------------------------------------------
- @rem Checking for permissions...
- if "%PROCESSOR_ARCHITECTURE%" equ "amd64" (
- "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system">nul 2>&1
- ) else (
- "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system">nul 2>&1
- )
- if '%errorlevel%' neq '0' (
- @rem Administrator permissions not found
- echo Requesting administrative privileges...
- goto UACPrompt
- ) else (
- @rem Administrator permissions found
- 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"
- @rem --------------------------------------------------------------------------
- set tempFile=%TEMP%\UnquottedPaths.txt
- if exist %tempFile% del %tempFile%
- wmic service get name,pathname,startmode,displayname /format:csv | findstr /i auto | findstr /i /v "C:\Windows\\" | findstr /i /v ^""" > %tempFile%
- for /f "tokens=2,4 delims=," %%a in (%tempFile%) do (
- reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\%%a" /v ImagePath /t REG_EXPAND_SZ /d "\"%%b"\" /f >NUL 2>&1
- echo Fixed path for service %%a,
- echo quoted the following path: %%b
- echo:
- )
- if exist %tempFile% del %tempFile%
- echo Successfully fixed unquotted paths!
- echo:
- echo [Press any key to close this window]
- pause >nul
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement