I'd like to be able to pass the username variable to a cmd command in a batch script so I can see if the current user is an administrator. I tried this code start cmd.exe /c "net user %username% > priv.txt"
It doesn't want to work though, whats the problem and is there a better way to do this? Any help or suggestions are appreciated. Thanks everyone.
Why You don't just use that %username% variable in your .bat file? Just tested echo %username% returns current user name - seems no problem using it; if You have any exact case and reason why its not working - clarify case. if you want to output to file use
echo %username% >> file.txt
net user %username% >> file.txt