Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...