51
General Computer Support / Re: Send to Set Always Run As Admin no longer working
« on: May 01, 2015, 10:46:47 am »
Redownloaded it just in case, but here is the contents:
I ran into this with windows 8.1 before, but this time I'm in Windows 7 Pro. It was working about a month ago. I've no idea what could be affecting it. Thanks, Shane.
Quote
@echo off
setlocal enableDelayedExpansion
:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************
setlocal DisableDelayedExpansion
set "batchPath=%~0"
setlocal EnableDelayedExpansion
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
ECHO UAC.ShellExecute "!batchPath!", "%*", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
"%temp%\OEgetPrivileges.vbs"
exit /B
:gotPrivileges
::::::::::::::::::::::::::::
:START
::::::::::::::::::::::::::::
@echo off
setlocal ENABLEDELAYEDEXPANSION
rem Take the cmd-line, remove all until the first parameter
set "params=!cmdcmdline:~0,-1!"
set "params=!params:*" =!"
set count=0
rem Split the parameters on spaces but respect the quotes
for %%G IN (!params!) do (
set /a count+=1
set "item_!count!=%%~G"
rem echo !count! %%~G
)
rem list the parameters
for /L %%n in (1,1,!count!) DO (
set "strexe=!item_%%n!"
set "strexe=!strexe:~-3!"
IF /I ["!strexe!"] EQU ["exe"] reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags" /f
IF /I ["!strexe!"] EQU ["exe"] reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /f
IF /I ["!strexe!"] EQU ["exe"] reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "!item_%%n!" /t REG_SZ /d "RUNASADMIN" /f
IF /I ["!strexe!"] EQU [".ex"] reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags" /f
IF /I ["!strexe!"] EQU [".ex"] reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /f
IF /I ["!strexe!"] EQU [".ex"] reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "!item_%%n!e" /t REG_SZ /d "RUNASADMIN" /f
)
exit
I ran into this with windows 8.1 before, but this time I'm in Windows 7 Pro. It was working about a month ago. I've no idea what could be affecting it. Thanks, Shane.