These work with ^escape or initial " :-
Code: Select all
ECHO E(xit^) or-alternatively C(lose^)
ECHO "E(xit) or-alternatively C(lose)
I am testing whether UAC intercepts creation and removal of %windir%\AdminTest,
and if it hinders then suggesting the user close and retry with "Run As Administrator"
This is the complete code from start to grief
Code: Select all
@echo off & setlocal EnableDelayedExpansion
CD /D %~dp0 & REM All files are here, not at stupid "Run As Administrator" default %windir%\
SET "UAC=%windir%\AdminTest" & IF EXIST !UAC! ( RD !UAC! & DEL /F /Q !UAC! )
MD !UAC! 2>NUL
RD !UAC! 2>NUL || (
ECHO Suggest "Right Click" then "Run As Administrator" to avoid probable UAC GRIEF.
ECHO E(xit^) or-alternatively C(lose^) 1
ECHO "E(xit) or-alternatively C(lose) 2
ECHO E(xit) or-alternatively C(lose) 3
ECHO GOT TO HERE
)
PAUSE
GOTO :EOF
It crashes without any pause, thus :-
Code: Select all
E:\T\CCleaner\v313\T6>TT
or-alternatively was unexpected at this time.
E:\T\CCleaner\v313\T6>
It works properly when I remove the guilty line
ECHO E(xit) or-alternatively C(lose) 3
Code: Select all
E:\T\CCleaner\v313\T6>TT
Suggest "Right Click" then "Run As Administrator" to avoid probable UAC GRIEF.
E(xit) or-alternatively C(lose) 1
"E(xit) or-alternatively C(lose) 2
GOT TO HERE
Press any key to continue . . .
Is this a well documented "feature" that I should have known about ?
NB
I am also horrified that when I "Run As Administrator" the current drive and directory get switched to C:\Windows
I think there are now unwanted output files that should have gone to the folder
E:\T\CCleaner\v313\T6
and now they are swimming around in
C:\Windows.
Bad "Run As Administrator" for doing that to me.
I am glad Macrium partition images have "got my back"
Regards
Alan