27 lines
750 B
Batchfile
27 lines
750 B
Batchfile
@echo off
|
|
chcp 65001 >nul
|
|
rem Speicherort der Batch als Arbeitsverzeichnis
|
|
cd /d "%~dp0"
|
|
net session >nul 2>&1 && goto :AdminBatch
|
|
rem selbststart als Admin
|
|
set "elevationCmdLine=cd /d "%cd%"&call "%~f0" %*"
|
|
set "elevationCmdLine=%elevationCmdLine:&=^&%"
|
|
set "elevator=%temp%\%~n0.elevate.js"
|
|
echo new ActiveXObject^("shell.application"^).ShellExecute^('cmd','/c %elevationCmdLine:\=\\%' ,'','runas',4^); >"%elevator%"
|
|
cscript //nologo "%elevator%"
|
|
exit /b
|
|
|
|
:AdminBatch
|
|
rem hier kommt alles rein was als Admin ausgeführt werden soll.
|
|
echo Hallo . Ich werde jetzt als Admin %UserName% ausgeführt.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if "%~1" neq "" (
|
|
echo Mir wurden folgende Parameter übergeben:
|
|
for %%a in (%*) do (echo %%a)
|
|
)
|
|
pause |