'trying to get administrative permission(without uac) in batch file

@echo off
goto check_Permissions

:check_Permissions
SET "C:\Users\BDAS\Desktop\check_admin=%~dp0"&SET "check_admin=%~dpf0"
net session >nul 2>nul & if errorlevel 1  check_admin "%~0" %*
if %errorLevel% == 0 (
    echo Success: Administrative permissions confirmed. > res_txt.txt
) else (
    echo Failure: Current permissions inadequate. > res_txt.txt
)

pause


Solution 1:[1]

Detecting elevation can be done more simply with openfiles:

openfiles > NUL 2>&1 && (
  echo Administrative permissions confirmed.
  exit /b 0
) else (
  echo Current permissions inadequate.
  exit /b 1
)

The full script to run notepad.exe with administrative privileges is here:

@echo off
setlocal enableextensions enabledelayedexpansion

REM Check admin mode, auto-elevate if required.
  openfiles > NUL 2>&1 || (
    REM Not elevated. Do it.
    echo createObject^("Shell.Application"^).shellExecute "%~dpnx0", "%*", "", "runas">"%TEMP%\%~n0.vbs"
    cscript /nologo "%TEMP%\%~n0.vbs"
    goto :eof
  )
  del /s /q "%TEMP%\%~n0.vbs" > NUL 2>&1
)

REM If here, then process is elevated. Otherwise, batch is already terminated and/or stuck in code above.

start "" notepad.exe
goto :eof

In no way you can bypass UAC, but by disabling it fully for the current account. If it was possible to do so, absolutely NO Windows machine connected to Internet would be virus-free since YEARS. But at least, the batch will handle automatically the elevation request, so if you forget to run it as Administrator, it will prompt you to allow elevation.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wisblade