Tzar Posted November 9, 2006 Posted November 9, 2006 I want to make a file that if a sertain command is denyed it trys something different. This is what i tryed (hard for me to describe with the code) net localgroup administrators /add %uname set /p error if %error% equ Goto nonadmin del k.bat exit There is code befor and after. but what im trying to create (on my own so i actuly learn about it and for a tut im makeing) is a file that trys to add a admin user and if it cant puts a new file in the startup folder for next time the admin logs in. Quote
Mick Posted November 10, 2006 Posted November 10, 2006 Do you mean like a check if the command executed properly? Such as: net localgroup administrators /add %uname% if %ERRORLEVEL% neq 0 goto failed echo The Command Was Successful! goto done :failed echo Tho Command Failed. :done exit Quote
Spartain X Posted November 11, 2006 Posted November 11, 2006 i would say %errorlevel% is the best way to go but it would net be as useful as it only check's if the last command executed properly. another thing to be since you are seeing if a account is added is add after the "net localgroup administrators /add %uname%" net localgroup administrators >> temp.log then run "type temp.log | find "[insert account you where adding]"" then check the %errorlevel% with an if command so if it's successful it would be print "success" and a else of "fail" so it will look like this net localgroup administrators /add %uname% net localgroup administrators >> temp.log type temp.log | find "[insert account you where adding]" if %ERRORLEVEL% EQU 0 goto failed ( echo "sucess" ) else ( "fail" ) this is a basic outline but should work well basically it tries to and does not worry about the out but of the command but it check's again in the admin list and if it a success of fail it prints it Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.