How to determine the username on a windows command shellHow to determine logged on user in Windows XP?How Can...

Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?

Traveling through the asteriod belt?

Digits in an algebraic irrational number

What is the lore-based reason that the Spectator has the Create Food and Water trait, instead of simply not requiring food and water?

Does paint affect EMI ability of enclosure?

Why zero tolerance on nudity in space?

How would an AI self awareness kill switch work?

How to deal with an incendiary email that was recalled

Why are the books in the Game of Thrones citadel library shelved spine inwards?

Why is mind meld hard for T'pol in Star Trek: Enterprise?

Find some digits of factorial 17

A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?

Can making a creature unable to attack after it has been assigned as an attacker remove it from combat?

Am I a Rude Number?

How can my powered armor quickly replace its ceramic plates?

Which one of these password policies is more secure?

Why publish a research paper when a blog post or a lecture slide can have more citation count than a journal paper?

Do authors have to be politically correct in article-writing?

If I delete my router's history can my ISP still provide it to my parents?

what does しにみえてる mean?

Table formatting top left corner caption

Can I string the D&D Starter Set campaign into another module, keeping the same characters?

Cookies - Should the toggles be on?

Would a National Army of mercenaries be a feasible idea?



How to determine the username on a windows command shell


How to determine logged on user in Windows XP?How Can I tell if the current user is Admin from Windows Command LineHow to determine logged on user in Windows XP?Problem with quotes around file names in Windows command shellHow do I determine if my Windows is 32-bit or 64-bit using a command?Is Remoteusername same as ComputerNameusername or username in windows 7/xp?Execute x86 PDFCreator.exe in the “Program Files (x86)” folder from x64 the command line w arguments?Perform command substitution Windows command-promptHow do I create a multiline text file with Echo in Windows command prompt?How to run internal cmd command from the msys shell?How to generically refer to the AppData folder on the Windows command line?How to determine Windows architecture version on disconnected volume?













-1















There are various suggestions on how to determine the current username on a windows command shell without using whoami, such as this question or this question. The generic answer seems to be echo %username%. However, when I do this (on Windows XP), the shell answers with %username%. Am I missing something?










share|improve this question

























  • It works in Windows7.

    – cliff2310
    May 25 '15 at 22:41






  • 1





    @cliff2310 you say it works on 7 but can you not see he tagged this XP and is asking about XP (That said, it should work on XP too)

    – barlop
    May 25 '15 at 22:44








  • 1





    It works fine on my XP system. Your observation will happen only if username is either not set, or set to the literal string %username%. To find out which, type set username. Both are unlikely, but my best guess is that you have run a batch file which uses username as a work variable and clears it on exit, so search your batch files for the string username (case insensitive search).

    – AFH
    May 25 '15 at 23:00











  • "As I said, it's a pentesting lab with deliberately broken machines." -- voting to close as off topic

    – DavidPostill
    May 25 '15 at 23:43











  • "deliberately broken" is to be understood in the sense of badly maintained, not in the sense of artificially misconfigured machines that would never be seen in the wild.

    – countermode
    May 26 '15 at 0:34
















-1















There are various suggestions on how to determine the current username on a windows command shell without using whoami, such as this question or this question. The generic answer seems to be echo %username%. However, when I do this (on Windows XP), the shell answers with %username%. Am I missing something?










share|improve this question

























  • It works in Windows7.

    – cliff2310
    May 25 '15 at 22:41






  • 1





    @cliff2310 you say it works on 7 but can you not see he tagged this XP and is asking about XP (That said, it should work on XP too)

    – barlop
    May 25 '15 at 22:44








  • 1





    It works fine on my XP system. Your observation will happen only if username is either not set, or set to the literal string %username%. To find out which, type set username. Both are unlikely, but my best guess is that you have run a batch file which uses username as a work variable and clears it on exit, so search your batch files for the string username (case insensitive search).

    – AFH
    May 25 '15 at 23:00











  • "As I said, it's a pentesting lab with deliberately broken machines." -- voting to close as off topic

    – DavidPostill
    May 25 '15 at 23:43











  • "deliberately broken" is to be understood in the sense of badly maintained, not in the sense of artificially misconfigured machines that would never be seen in the wild.

    – countermode
    May 26 '15 at 0:34














-1












-1








-1








There are various suggestions on how to determine the current username on a windows command shell without using whoami, such as this question or this question. The generic answer seems to be echo %username%. However, when I do this (on Windows XP), the shell answers with %username%. Am I missing something?










share|improve this question
















There are various suggestions on how to determine the current username on a windows command shell without using whoami, such as this question or this question. The generic answer seems to be echo %username%. However, when I do this (on Windows XP), the shell answers with %username%. Am I missing something?







windows-xp command-line user-accounts






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 20 '17 at 10:17









Community

1




1










asked May 25 '15 at 22:19









countermodecountermode

6662920




6662920













  • It works in Windows7.

    – cliff2310
    May 25 '15 at 22:41






  • 1





    @cliff2310 you say it works on 7 but can you not see he tagged this XP and is asking about XP (That said, it should work on XP too)

    – barlop
    May 25 '15 at 22:44








  • 1





    It works fine on my XP system. Your observation will happen only if username is either not set, or set to the literal string %username%. To find out which, type set username. Both are unlikely, but my best guess is that you have run a batch file which uses username as a work variable and clears it on exit, so search your batch files for the string username (case insensitive search).

    – AFH
    May 25 '15 at 23:00











  • "As I said, it's a pentesting lab with deliberately broken machines." -- voting to close as off topic

    – DavidPostill
    May 25 '15 at 23:43











  • "deliberately broken" is to be understood in the sense of badly maintained, not in the sense of artificially misconfigured machines that would never be seen in the wild.

    – countermode
    May 26 '15 at 0:34



















  • It works in Windows7.

    – cliff2310
    May 25 '15 at 22:41






  • 1





    @cliff2310 you say it works on 7 but can you not see he tagged this XP and is asking about XP (That said, it should work on XP too)

    – barlop
    May 25 '15 at 22:44








  • 1





    It works fine on my XP system. Your observation will happen only if username is either not set, or set to the literal string %username%. To find out which, type set username. Both are unlikely, but my best guess is that you have run a batch file which uses username as a work variable and clears it on exit, so search your batch files for the string username (case insensitive search).

    – AFH
    May 25 '15 at 23:00











  • "As I said, it's a pentesting lab with deliberately broken machines." -- voting to close as off topic

    – DavidPostill
    May 25 '15 at 23:43











  • "deliberately broken" is to be understood in the sense of badly maintained, not in the sense of artificially misconfigured machines that would never be seen in the wild.

    – countermode
    May 26 '15 at 0:34

















It works in Windows7.

– cliff2310
May 25 '15 at 22:41





It works in Windows7.

– cliff2310
May 25 '15 at 22:41




1




1





@cliff2310 you say it works on 7 but can you not see he tagged this XP and is asking about XP (That said, it should work on XP too)

– barlop
May 25 '15 at 22:44







@cliff2310 you say it works on 7 but can you not see he tagged this XP and is asking about XP (That said, it should work on XP too)

– barlop
May 25 '15 at 22:44






1




1





It works fine on my XP system. Your observation will happen only if username is either not set, or set to the literal string %username%. To find out which, type set username. Both are unlikely, but my best guess is that you have run a batch file which uses username as a work variable and clears it on exit, so search your batch files for the string username (case insensitive search).

– AFH
May 25 '15 at 23:00





It works fine on my XP system. Your observation will happen only if username is either not set, or set to the literal string %username%. To find out which, type set username. Both are unlikely, but my best guess is that you have run a batch file which uses username as a work variable and clears it on exit, so search your batch files for the string username (case insensitive search).

– AFH
May 25 '15 at 23:00













"As I said, it's a pentesting lab with deliberately broken machines." -- voting to close as off topic

– DavidPostill
May 25 '15 at 23:43





"As I said, it's a pentesting lab with deliberately broken machines." -- voting to close as off topic

– DavidPostill
May 25 '15 at 23:43













"deliberately broken" is to be understood in the sense of badly maintained, not in the sense of artificially misconfigured machines that would never be seen in the wild.

– countermode
May 26 '15 at 0:34





"deliberately broken" is to be understood in the sense of badly maintained, not in the sense of artificially misconfigured machines that would never be seen in the wild.

– countermode
May 26 '15 at 0:34










3 Answers
3






active

oldest

votes


















1














maybe you are missing the USERNAME environment variable for some reason. Run the set command and it will list the environment variables and their values. My XP has USERNAME and I didn't add it, so XP has it.. it's strange yours doesn't. But run set and see what you have



A bunch of environment variables have the user



TEMP=C:DOCUME~1UserLOCALS~1Temp
TMP=C:DOCUME~1UserLOCALS~1Temp
USERNAME=user
USERPROFILE=C:Documents and Settingsuser


Added



In an example similar to the one you are in.. Here I have logged into the machine remotely, it runs bvsshserver (bitvise ssh server aka winsshd) (which when logged into even from cygwin client, will give a windows command line) though openssh server via cygwin gives bash.. You can use the openssh client in cygwin to log into bitvise sshd and get a windows command line



SystemRoot=C:WINDOWS
TEMP=C:DOCUME~1WINSSH~1LOCALS~1Temp
TMP=C:DOCUME~1WINSSH~1LOCALS~1Temp
USERNAME=WinSSHD_VirtualUsers
USERPROFILE=C:Documents and SettingsWinSSHD_VirtualUsers
VIRTGROUP=Virtual Users
VIRTUSER=user
windir=C:WINDOWS


C:>whoami
WinSSHD_VirtualUsers

C:>


In this case "VIRTUSER" has the username, though different to the one shown by whoami.



What SSH server(or remote logging in program server) does your XP machine run?






share|improve this answer


























  • Well, this popped up in a pentesting lab. I got a shell on this XP machine and I wondered who I am (i.e. whose privileges I have). set is a nice suggestion, although it didn't tell a lot in the particular situation.

    – countermode
    May 25 '15 at 22:53











  • @countermode what is the server? I guess it can depend on that

    – barlop
    May 25 '15 at 23:00











  • It's a Win XP, apparently no service packs installed. username is not set and whoami is not installed.

    – countermode
    May 25 '15 at 23:08











  • @countermode it can't be the no service packs.. 'cos are you're telling me he has no %TEMP% either? i'd be surprised if win xp pre sp1 was so limited! how many users are there! maybe look in c:documents and settings see how many folders ther are. If the machine has so many things removed maybe it only has one user profile there! (that said.. no doubt i have no winsshd virtual user listed in my documents and settings).

    – barlop
    May 25 '15 at 23:10













  • As I said, it's a pentesting lab with deliberately broken machines. Wait... %TEMP% is set.

    – countermode
    May 25 '15 at 23:17





















1














You're not missing anything. Perhaps you're running it in powershell? If you're not getting the correct value returned from cmd, that's something you'll have to investigate further.



When in a Windows command prompt (cmd not PowerShell), enter:



echo %username%


When in PowerShell, enter:



# Returns computername/username
whoami
# Returns username
echo $env:username
# Returns table containing computer/usernem
Get-WMIObject -class Win32_ComputerSystem | select username





share|improve this answer































    0














    If you're doing this as part of a pentesting lab, you can use Kali's inbuilt whoami.exe located at



    /usr/share/windows-binaries/whoami.exe


    Just copy it over and run on the Win XP machine.






    share|improve this answer








    New contributor




    Ivan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.




















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f919453%2fhow-to-determine-the-username-on-a-windows-command-shell%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      maybe you are missing the USERNAME environment variable for some reason. Run the set command and it will list the environment variables and their values. My XP has USERNAME and I didn't add it, so XP has it.. it's strange yours doesn't. But run set and see what you have



      A bunch of environment variables have the user



      TEMP=C:DOCUME~1UserLOCALS~1Temp
      TMP=C:DOCUME~1UserLOCALS~1Temp
      USERNAME=user
      USERPROFILE=C:Documents and Settingsuser


      Added



      In an example similar to the one you are in.. Here I have logged into the machine remotely, it runs bvsshserver (bitvise ssh server aka winsshd) (which when logged into even from cygwin client, will give a windows command line) though openssh server via cygwin gives bash.. You can use the openssh client in cygwin to log into bitvise sshd and get a windows command line



      SystemRoot=C:WINDOWS
      TEMP=C:DOCUME~1WINSSH~1LOCALS~1Temp
      TMP=C:DOCUME~1WINSSH~1LOCALS~1Temp
      USERNAME=WinSSHD_VirtualUsers
      USERPROFILE=C:Documents and SettingsWinSSHD_VirtualUsers
      VIRTGROUP=Virtual Users
      VIRTUSER=user
      windir=C:WINDOWS


      C:>whoami
      WinSSHD_VirtualUsers

      C:>


      In this case "VIRTUSER" has the username, though different to the one shown by whoami.



      What SSH server(or remote logging in program server) does your XP machine run?






      share|improve this answer


























      • Well, this popped up in a pentesting lab. I got a shell on this XP machine and I wondered who I am (i.e. whose privileges I have). set is a nice suggestion, although it didn't tell a lot in the particular situation.

        – countermode
        May 25 '15 at 22:53











      • @countermode what is the server? I guess it can depend on that

        – barlop
        May 25 '15 at 23:00











      • It's a Win XP, apparently no service packs installed. username is not set and whoami is not installed.

        – countermode
        May 25 '15 at 23:08











      • @countermode it can't be the no service packs.. 'cos are you're telling me he has no %TEMP% either? i'd be surprised if win xp pre sp1 was so limited! how many users are there! maybe look in c:documents and settings see how many folders ther are. If the machine has so many things removed maybe it only has one user profile there! (that said.. no doubt i have no winsshd virtual user listed in my documents and settings).

        – barlop
        May 25 '15 at 23:10













      • As I said, it's a pentesting lab with deliberately broken machines. Wait... %TEMP% is set.

        – countermode
        May 25 '15 at 23:17


















      1














      maybe you are missing the USERNAME environment variable for some reason. Run the set command and it will list the environment variables and their values. My XP has USERNAME and I didn't add it, so XP has it.. it's strange yours doesn't. But run set and see what you have



      A bunch of environment variables have the user



      TEMP=C:DOCUME~1UserLOCALS~1Temp
      TMP=C:DOCUME~1UserLOCALS~1Temp
      USERNAME=user
      USERPROFILE=C:Documents and Settingsuser


      Added



      In an example similar to the one you are in.. Here I have logged into the machine remotely, it runs bvsshserver (bitvise ssh server aka winsshd) (which when logged into even from cygwin client, will give a windows command line) though openssh server via cygwin gives bash.. You can use the openssh client in cygwin to log into bitvise sshd and get a windows command line



      SystemRoot=C:WINDOWS
      TEMP=C:DOCUME~1WINSSH~1LOCALS~1Temp
      TMP=C:DOCUME~1WINSSH~1LOCALS~1Temp
      USERNAME=WinSSHD_VirtualUsers
      USERPROFILE=C:Documents and SettingsWinSSHD_VirtualUsers
      VIRTGROUP=Virtual Users
      VIRTUSER=user
      windir=C:WINDOWS


      C:>whoami
      WinSSHD_VirtualUsers

      C:>


      In this case "VIRTUSER" has the username, though different to the one shown by whoami.



      What SSH server(or remote logging in program server) does your XP machine run?






      share|improve this answer


























      • Well, this popped up in a pentesting lab. I got a shell on this XP machine and I wondered who I am (i.e. whose privileges I have). set is a nice suggestion, although it didn't tell a lot in the particular situation.

        – countermode
        May 25 '15 at 22:53











      • @countermode what is the server? I guess it can depend on that

        – barlop
        May 25 '15 at 23:00











      • It's a Win XP, apparently no service packs installed. username is not set and whoami is not installed.

        – countermode
        May 25 '15 at 23:08











      • @countermode it can't be the no service packs.. 'cos are you're telling me he has no %TEMP% either? i'd be surprised if win xp pre sp1 was so limited! how many users are there! maybe look in c:documents and settings see how many folders ther are. If the machine has so many things removed maybe it only has one user profile there! (that said.. no doubt i have no winsshd virtual user listed in my documents and settings).

        – barlop
        May 25 '15 at 23:10













      • As I said, it's a pentesting lab with deliberately broken machines. Wait... %TEMP% is set.

        – countermode
        May 25 '15 at 23:17
















      1












      1








      1







      maybe you are missing the USERNAME environment variable for some reason. Run the set command and it will list the environment variables and their values. My XP has USERNAME and I didn't add it, so XP has it.. it's strange yours doesn't. But run set and see what you have



      A bunch of environment variables have the user



      TEMP=C:DOCUME~1UserLOCALS~1Temp
      TMP=C:DOCUME~1UserLOCALS~1Temp
      USERNAME=user
      USERPROFILE=C:Documents and Settingsuser


      Added



      In an example similar to the one you are in.. Here I have logged into the machine remotely, it runs bvsshserver (bitvise ssh server aka winsshd) (which when logged into even from cygwin client, will give a windows command line) though openssh server via cygwin gives bash.. You can use the openssh client in cygwin to log into bitvise sshd and get a windows command line



      SystemRoot=C:WINDOWS
      TEMP=C:DOCUME~1WINSSH~1LOCALS~1Temp
      TMP=C:DOCUME~1WINSSH~1LOCALS~1Temp
      USERNAME=WinSSHD_VirtualUsers
      USERPROFILE=C:Documents and SettingsWinSSHD_VirtualUsers
      VIRTGROUP=Virtual Users
      VIRTUSER=user
      windir=C:WINDOWS


      C:>whoami
      WinSSHD_VirtualUsers

      C:>


      In this case "VIRTUSER" has the username, though different to the one shown by whoami.



      What SSH server(or remote logging in program server) does your XP machine run?






      share|improve this answer















      maybe you are missing the USERNAME environment variable for some reason. Run the set command and it will list the environment variables and their values. My XP has USERNAME and I didn't add it, so XP has it.. it's strange yours doesn't. But run set and see what you have



      A bunch of environment variables have the user



      TEMP=C:DOCUME~1UserLOCALS~1Temp
      TMP=C:DOCUME~1UserLOCALS~1Temp
      USERNAME=user
      USERPROFILE=C:Documents and Settingsuser


      Added



      In an example similar to the one you are in.. Here I have logged into the machine remotely, it runs bvsshserver (bitvise ssh server aka winsshd) (which when logged into even from cygwin client, will give a windows command line) though openssh server via cygwin gives bash.. You can use the openssh client in cygwin to log into bitvise sshd and get a windows command line



      SystemRoot=C:WINDOWS
      TEMP=C:DOCUME~1WINSSH~1LOCALS~1Temp
      TMP=C:DOCUME~1WINSSH~1LOCALS~1Temp
      USERNAME=WinSSHD_VirtualUsers
      USERPROFILE=C:Documents and SettingsWinSSHD_VirtualUsers
      VIRTGROUP=Virtual Users
      VIRTUSER=user
      windir=C:WINDOWS


      C:>whoami
      WinSSHD_VirtualUsers

      C:>


      In this case "VIRTUSER" has the username, though different to the one shown by whoami.



      What SSH server(or remote logging in program server) does your XP machine run?







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited May 25 '15 at 23:02

























      answered May 25 '15 at 22:47









      barlopbarlop

      15.6k2590149




      15.6k2590149













      • Well, this popped up in a pentesting lab. I got a shell on this XP machine and I wondered who I am (i.e. whose privileges I have). set is a nice suggestion, although it didn't tell a lot in the particular situation.

        – countermode
        May 25 '15 at 22:53











      • @countermode what is the server? I guess it can depend on that

        – barlop
        May 25 '15 at 23:00











      • It's a Win XP, apparently no service packs installed. username is not set and whoami is not installed.

        – countermode
        May 25 '15 at 23:08











      • @countermode it can't be the no service packs.. 'cos are you're telling me he has no %TEMP% either? i'd be surprised if win xp pre sp1 was so limited! how many users are there! maybe look in c:documents and settings see how many folders ther are. If the machine has so many things removed maybe it only has one user profile there! (that said.. no doubt i have no winsshd virtual user listed in my documents and settings).

        – barlop
        May 25 '15 at 23:10













      • As I said, it's a pentesting lab with deliberately broken machines. Wait... %TEMP% is set.

        – countermode
        May 25 '15 at 23:17





















      • Well, this popped up in a pentesting lab. I got a shell on this XP machine and I wondered who I am (i.e. whose privileges I have). set is a nice suggestion, although it didn't tell a lot in the particular situation.

        – countermode
        May 25 '15 at 22:53











      • @countermode what is the server? I guess it can depend on that

        – barlop
        May 25 '15 at 23:00











      • It's a Win XP, apparently no service packs installed. username is not set and whoami is not installed.

        – countermode
        May 25 '15 at 23:08











      • @countermode it can't be the no service packs.. 'cos are you're telling me he has no %TEMP% either? i'd be surprised if win xp pre sp1 was so limited! how many users are there! maybe look in c:documents and settings see how many folders ther are. If the machine has so many things removed maybe it only has one user profile there! (that said.. no doubt i have no winsshd virtual user listed in my documents and settings).

        – barlop
        May 25 '15 at 23:10













      • As I said, it's a pentesting lab with deliberately broken machines. Wait... %TEMP% is set.

        – countermode
        May 25 '15 at 23:17



















      Well, this popped up in a pentesting lab. I got a shell on this XP machine and I wondered who I am (i.e. whose privileges I have). set is a nice suggestion, although it didn't tell a lot in the particular situation.

      – countermode
      May 25 '15 at 22:53





      Well, this popped up in a pentesting lab. I got a shell on this XP machine and I wondered who I am (i.e. whose privileges I have). set is a nice suggestion, although it didn't tell a lot in the particular situation.

      – countermode
      May 25 '15 at 22:53













      @countermode what is the server? I guess it can depend on that

      – barlop
      May 25 '15 at 23:00





      @countermode what is the server? I guess it can depend on that

      – barlop
      May 25 '15 at 23:00













      It's a Win XP, apparently no service packs installed. username is not set and whoami is not installed.

      – countermode
      May 25 '15 at 23:08





      It's a Win XP, apparently no service packs installed. username is not set and whoami is not installed.

      – countermode
      May 25 '15 at 23:08













      @countermode it can't be the no service packs.. 'cos are you're telling me he has no %TEMP% either? i'd be surprised if win xp pre sp1 was so limited! how many users are there! maybe look in c:documents and settings see how many folders ther are. If the machine has so many things removed maybe it only has one user profile there! (that said.. no doubt i have no winsshd virtual user listed in my documents and settings).

      – barlop
      May 25 '15 at 23:10







      @countermode it can't be the no service packs.. 'cos are you're telling me he has no %TEMP% either? i'd be surprised if win xp pre sp1 was so limited! how many users are there! maybe look in c:documents and settings see how many folders ther are. If the machine has so many things removed maybe it only has one user profile there! (that said.. no doubt i have no winsshd virtual user listed in my documents and settings).

      – barlop
      May 25 '15 at 23:10















      As I said, it's a pentesting lab with deliberately broken machines. Wait... %TEMP% is set.

      – countermode
      May 25 '15 at 23:17







      As I said, it's a pentesting lab with deliberately broken machines. Wait... %TEMP% is set.

      – countermode
      May 25 '15 at 23:17















      1














      You're not missing anything. Perhaps you're running it in powershell? If you're not getting the correct value returned from cmd, that's something you'll have to investigate further.



      When in a Windows command prompt (cmd not PowerShell), enter:



      echo %username%


      When in PowerShell, enter:



      # Returns computername/username
      whoami
      # Returns username
      echo $env:username
      # Returns table containing computer/usernem
      Get-WMIObject -class Win32_ComputerSystem | select username





      share|improve this answer




























        1














        You're not missing anything. Perhaps you're running it in powershell? If you're not getting the correct value returned from cmd, that's something you'll have to investigate further.



        When in a Windows command prompt (cmd not PowerShell), enter:



        echo %username%


        When in PowerShell, enter:



        # Returns computername/username
        whoami
        # Returns username
        echo $env:username
        # Returns table containing computer/usernem
        Get-WMIObject -class Win32_ComputerSystem | select username





        share|improve this answer


























          1












          1








          1







          You're not missing anything. Perhaps you're running it in powershell? If you're not getting the correct value returned from cmd, that's something you'll have to investigate further.



          When in a Windows command prompt (cmd not PowerShell), enter:



          echo %username%


          When in PowerShell, enter:



          # Returns computername/username
          whoami
          # Returns username
          echo $env:username
          # Returns table containing computer/usernem
          Get-WMIObject -class Win32_ComputerSystem | select username





          share|improve this answer













          You're not missing anything. Perhaps you're running it in powershell? If you're not getting the correct value returned from cmd, that's something you'll have to investigate further.



          When in a Windows command prompt (cmd not PowerShell), enter:



          echo %username%


          When in PowerShell, enter:



          # Returns computername/username
          whoami
          # Returns username
          echo $env:username
          # Returns table containing computer/usernem
          Get-WMIObject -class Win32_ComputerSystem | select username






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 26 '15 at 7:59









          Alex AtkinsonAlex Atkinson

          2,735913




          2,735913























              0














              If you're doing this as part of a pentesting lab, you can use Kali's inbuilt whoami.exe located at



              /usr/share/windows-binaries/whoami.exe


              Just copy it over and run on the Win XP machine.






              share|improve this answer








              New contributor




              Ivan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.

























                0














                If you're doing this as part of a pentesting lab, you can use Kali's inbuilt whoami.exe located at



                /usr/share/windows-binaries/whoami.exe


                Just copy it over and run on the Win XP machine.






                share|improve this answer








                New contributor




                Ivan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.























                  0












                  0








                  0







                  If you're doing this as part of a pentesting lab, you can use Kali's inbuilt whoami.exe located at



                  /usr/share/windows-binaries/whoami.exe


                  Just copy it over and run on the Win XP machine.






                  share|improve this answer








                  New contributor




                  Ivan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  If you're doing this as part of a pentesting lab, you can use Kali's inbuilt whoami.exe located at



                  /usr/share/windows-binaries/whoami.exe


                  Just copy it over and run on the Win XP machine.







                  share|improve this answer








                  New contributor




                  Ivan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  Ivan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 13 mins ago









                  IvanIvan

                  1




                  1




                  New contributor




                  Ivan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  Ivan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  Ivan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f919453%2fhow-to-determine-the-username-on-a-windows-command-shell%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...

                      Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

                      VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...