K1000 Won't Run cmd command with UAC
06/26/2018 936 views
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?
if %errorlevel% == 0 (
) else (
echo Requesting administrative privileges...
fsutil dirty query %systemdrive% >nul
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
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %~1", "", "runas", 1 >> "%temp%\getadmin.vbs"
Be the first to answer this question