ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 배치파일 관리자모드로 자동실행
    컴퓨터/배치파일 2015. 9. 12. 11:28

    @ECHO OFF

    Color 1F

    SETLOCAL ENABLEDELAYEDEXPANSION

    pushd %~dp0


    FSUTIL dirty query "!SYSTEMDRIVE!" >nul

    IF not !ERRORLEVEL! equ 0 (

        ( ECHO SET UAC = CreateObject^("Shell.Application"^)

            ECHO UAC.ShellExecute "%~dpf0", ELAV, "", "runas", 1

        )> "!TEMP!\OEgetPrivileges.vbs"

        "!TEMP!\OEgetPrivileges.vbs"

        DEL "!TEMP!\OEgetPrivileges.vbs"

        EXIT /B

    )

    ------------------------------------------------------------


    @echo off

    color 0a

    setlocal EnableExtensions

    setlocal EnableDelayedExpansion


    cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || (  echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )


    ---------------------------------------------------------------------------

    @echo off


    bcdedit > nul || goto getAdmin

    pushd %~dp0


    :getAdmin

    echo Set objShell=CreateObject("Shell.Application") > "%temp%\getadmin.vbs"

    echo objShell.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"

    cscript //nologo "%temp%\getadmin.vbs"

    del /q "%temp%\getadmin.vbs"

    exit/b

    댓글

Designed by Tistory.