K1000 Won't Run cmd command with UAC
Hello Everyone,
I built managed installs for SQL 2008, 2012 and 2014. Now in order to use Management Studio properly on Windows 10, they need to run as an admin so I created a script to make them work as an admin for all users on the computer. I built the below batch file code which basically forces cmd to run with admin rights and make the required change to the Management Studio file (in the below example for SQL 2012). If I run the batch file locally it always works but when I push it through K1000 as part of my MI or script it never works. Any thoughts?
@echo on
call :isAdmin
if %errorlevel% == 0 (
goto :run
) else (
echo Requesting administrative privileges...
goto :UACPrompt
)
exit /b
:isAdmin
fsutil dirty query %systemdrive% >nul
exit /b
:run
setlocal
set "reg_key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
reg add "%reg_key%" /v "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe" /d "RUNASADMIN" /f
exit /b
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %~1", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
3 Comments
[ + ] Show comments
Answers (0)
Please log in to answer
Be the first to answer this question
set "reg_key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
reg add "%reg_key%" /v "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe" /d "RUNASADMIN" /f - clozecall 6 years ago
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe" /d "RUNASADMIN" /f /reg:64
You also might want to check the path, I don't have a machine with the Management Studio installed, but I'm pretty sure it's bin and not binn. - chucksteel 6 years ago