%username% variable in batch - Printable Version +- 0Day Forums (https://0day.red) +-- Forum: Coding (https://0day.red/Forum-Coding) +--- Forum: .bat & .wsf & .cmd (https://0day.red/Forum-bat-wsf-cmd) +--- Thread: %username% variable in batch (/Thread-username-variable-in-batch) |
%username% variable in batch - sibie260 - 07-23-2023 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. RE: %username% variable in batch - merlinmerlina333 - 07-23-2023 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 |