Can anyone fathom why someone would have this not work for them Example person with difficulties Code: @color 06 cls mode con: cols=49 lines=12 md %windir%\TrilogyAdminTest 2>NUL if %errorlevel%==0 ( rd %windir%\TrilogyAdminTest goto mainmenu ) else ( echo Right click Trilogy and run as administrator echo. pause goto end ) Thank you
Try this: Code: md "%TEMP%\TrilogyAdminTest" >NUL IF NOT ERRORLEVEL 1 goto mainmenu echo Right click Trilogy and run as administrator echo. pause goto end And add this to initial code for mainmenu label Code: :mainmenu rd /S /Q "%TEMP%\TrilogyAdminTest" >NUL Please post reports
The main problem is AV blocking batch changes to %WINDIR% folder... My code safest for this is problem Test with you...
Try this is code for new compilation: Code: @echo off @color 06 cls mode con: cols=49 lines=12 md "%TEMP%\TrilogyAdminTest" >NUL IF NOT ERRORLEVEL 1 goto mainmenu echo Right click Trilogy and run as administrator echo. pause goto end Safest and minimal method...
Ok, updating code: Code: @echo off @color 06 cls mode con: cols=49 lines=12 IF EXIST "%TEMP%\TrilogyAdminTest" rd /S /Q "%TEMP%\TrilogyAdminTest" >NUL md "%TEMP%\TrilogyAdminTest" >NUL IF ERRORLEVEL 0 goto mainmenu echo Right click Trilogy and run as administrator echo. pause goto end Works fine on Windows 7 / XP
It is still unconfirmed as to why he had this problem on two separate OS's? And I've only had two reports about this one of which I think users solved on own So why rare problem occurs is unknown Wait will we for test
And patient you must be... I havent got the time untill tomorrow. BTW Im using Comodo Internet Security. Disabled "Sandbox" and "Defense + Security" but not AV.
That code is incorrect! IF ERRORLEVEL 0 means IF THE ERRORLEVEL IS 0 OR HIGHER, which is always the case. You may be better off using this kind of syntax Code: IF NOT EXIST "%SYSTEMROOT%\TRILOGYADMINTEST" ( MD "%SYSTEMROOT%\TRILOGYADMINTEST" 2>NUL && ( RD %SYSTEMROOT%\TRILOGYADMINTEST ) || ( ECHO=Right click %~nx0 and Run as administrator. ECHO= ECHO=Press any key to Exit. PAUSE>NUL GOTO end )
lol, The ERRORLEVEL 0 it's NO-ERRORS Return code for latest command If the folder is created with success, ERRORLEVEL = 0 If occur any error of the creation, the ERRORLEVEL is NOT = 0, validating the code .
You are mistaking ERRORLEVEL with %ERRORLEVEL%, IF ERRORLEVEL 0 means if the Error Level is at least 0, which is true of ERRORLEVEL 0, ERRORLEVEL 1, ERRORLEVEL 2 etc. If your folder is created without success, i.e. not created, then an Error level of 1 OR More may be returned, they would howecver still be validated by that line. In your case you should have validated by using IF NOT ERRORLEVEL 1, that would have been true for anything other than an Error Level of 0, which was your goal.
I wasn't trying to fix the random error your users were having, I was simply correcting the error in the information with which you were provided. Have you thought about changing the method of checking for Elevation to using the registry instead of writing a file? You could try something like this: Code: REG QUERY "HKU\S-1-5-19" >NUL 2>&1 && ( GOTO NEXT ) || ( ECHO=Right click %~nx0 and Run as administrator. ECHO= ECHO=Press any key to Exit. PAUSE>NUL GOTO end )
I understand you wern't that is why I suggested going to trinity thread where I explained it more and posts also Thank you so much for your help compo I hadn't thought of that am waiting on candlestick in Trilogy thread to confirm my last post code is working Works for me Please go there Also check this post out http://forums.mydigitallife.net/threads/28566-Creating-task-in-batch-with-multiple-triggers Thanks