My UAC function
Posted: 05 Oct 2013 08:37
Hi everyone.
I am having an issue with my UAC check function:
I call it when I write a log sting line to a file like this:
What am I doing wrong?
I use it in my script like so as well an nothing, just jumps to the first label:
ANy idea?
Thanks
Adrianvdh
I am having an issue with my UAC check function:
Code: Select all
:checkfileUAC
pause
set "/h="&set "/l="&set "/dl="&set "/ui="&set "/du="
for %%a in (%*) do (
if "%%~a"=="/h" ( set "/h=true"
) else if "%%~a"=="/l" ( set "/l=true"
) else if "%%~a"=="/dl" ( set "/dl=true"
) else if "%%~a"=="/ui" ( set "/ui=true"
) else if "%%~a"=="/du" set "/du=true"
)
if defined /h set "UACcheckfile=%HostFileName%" && set "writeError=Writing hosts to file"
if defined /l set "UACcheckfile=%logdir%" && set "writeError=Writing log to file"
if defined /dl set "UACcheckfile=%logdir%" && set "writeError=Deleting log file"
if defined /ui set "UACcheckfile=%updateinfofile%" && set "writeError=Storing update information to file"
if defined /du set "UACcheckfile=%newversionupdatefile%" && set "writeError=Downloading new update file"
if exist "%UACcheckfile%" attrib -r "%UACcheckfile%"
for /F %%a in ('^(^(set "X=" ^< nul^)^>^>"%UACcheckfile%"^)2^>^&1') do (
goto Errorwritefiles )
exit /b
I call it when I write a log sting line to a file like this:
Code: Select all
call :checkfileUAC "/l" && if "%logmode%"=="Enabled" if "%logtype%"=="Detailed" echo [%time%] [Msg]>>"%logdir%"
What am I doing wrong?
I use it in my script like so as well an nothing, just jumps to the first label:
Code: Select all
choice /C 12r /N /M "Make your selection: "
if errorlevel 3 cls & goto restart
if errorlevel 2 ( set mainmenuvar=Text1
goto mainmenuloginput )
if errorlevel 1 ( set mainmenuvar=Text2
goto mainmenuloginput )
:mainmenuloginput
if "%logmode%"=="Enabled" call :checkfileUAC "/l" && if "%logtype%"=="Detailed" echo [%time%] [Msg: %mainmenuvar%]>>"%logdir%"
if errorlevel 2 goto 222
if errorlevel 1 goto 111
:333
echo No redirection label here
pause
:111
echo 111
pause
:222
echo 222
pause
exit
ANy idea?
Thanks
Adrianvdh