Windows current user command

Windows current user command

Starts a new instance of the command interpreter, Cmd.exe. If used without parameters, cmd displays the version and copyright information of the operating system.

Syntax

Parameters

Parameter Description
/c Carries out the command specified by string and then stops.
/k Carries out the command specified by string and continues.
/s Modifies the treatment of string after /c or /k.
/q Turns the echo off.
/d Disables execution of AutoRun commands.
/a Formats internal command output to a pipe or a file as American National Standards Institute (ANSI).
/u Formats internal command output to a pipe or a file as Unicode.
/t: < | > Sets the background (b) and foreground (f) colors.
/e:on Enables command extensions.
/e:off Disables commands extensions.
/f:on Enables file and directory name completion.
/f:off Disables file and directory name completion.
/v:on Enables delayed environment variable expansion.
/v:off Disables delayed environment variable expansion.
Specifies the command you want to carry out.
/? Displays help at the command prompt.

The following table lists valid hexadecimal digits that you can use as the values for and :

Value Color
0 Black
1 Blue
2 Green
3 Aqua
4 Red
5 Purple
6 Yellow
7 White
8 Gray
9 Light blue
a Light green
b Light aqua
c Light red
d Light purple
e Light yellow
f Bright white

Remarks

To use multiple commands for , separate them by the command separator && and enclose them in quotation marks. For example:

If you specify /c or /k, cmd processes, the remainder of string, and the quotation marks are preserved only if all of the following conditions are met:

You don’t also use /s.

You use exactly one set of quotation marks.

You don’t use any special characters within the quotation marks (for example: & ( ) @ ^ | ).

You use one or more white-space characters within the quotation marks.

The string within quotation marks is the name of an executable file.

If the previous conditions aren’t met, string is processed by examining the first character to verify whether it is an opening quotation mark. If the first character is an opening quotation mark, it is stripped along with the closing quotation mark. Any text following the closing quotation marks is preserved.

If you don’t specify /d in string, Cmd.exe looks for the following registry subkeys:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun\REG_SZ

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun\REG_EXPAND_SZ

If one or both registry subkeys are present, they’re executed before all other variables.

Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

You can disable command extensions for a particular process by using /e:off. You can enable or disable extensions for all cmd command-line options on a computer or user session by setting the following REG_DWORD values:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD

Set the REG_DWORD value to either 0Г—1 (enabled) or 0Г—0 (disabled) in the registry by using Regedit.exe. User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.

Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

When you enable command extensions, the following commands are affected:

assoc

call

chdir (cd)

color

del (erase)

endlocal

for

ftype

goto

if

mkdir (md)

popd

prompt

pushd

set

setlocal

shift

start (also includes changes to external command processes)

If you enable delayed environment variable expansion, you can use the exclamation point character to substitute the value of an environment variable at run time.

File and directory name completion is not enabled by default. You can enable or disable file name completion for a particular process of the cmd command with /f:<on | off>. You can enable or disable file and directory name completion for all processes of the cmd command on a computer or for a user logon session by setting the following REG_DWORD values:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD

To set the REG_DWORD value, run Regedit.exe and use the hexadecimal value of a control character for a particular function (for example, 0Г—9 is TAB and 0Г—08 is BACKSPACE). User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.

Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

If you enable file and directory name completion by using /f:on, use CTRL+D for directory name completion and CTRL+F for file name completion. To disable a particular completion character in the registry, use the value for white space [0Г—20] because it is not a valid control character.

Pressing CTRL+D or CTRL+F, processes the file and directory name completion. These key combination functions append a wildcard character to string (if one is not present), builds a list of paths that match, and then displays the first matching path.

If none of the paths match, the file and directory name completion function beeps and does not change the display. To move through the list of matching paths, press CTRL+D or CTRL+F repeatedly. To move through the list backwards, press the SHIFT key and CTRL+D or CTRL+F simultaneously. To discard the saved list of matching paths and generate a new list, edit string and press CTRL+D or CTRL+F. If you switch between CTRL+D and CTRL+F, the saved list of matching paths is discarded and a new list is generated. The only difference between the key combinations CTRL+D and CTRL+F is that CTRL+D only matches directory names and CTRL+F matches both file and directory names. If you use file and directory name completion on any of the built-in directory commands (that is, CD, MD, or RD), directory completion is assumed.

File and directory name completion correctly processes file names that contain white space or special characters if you place quotation marks around the matching path.

You must use quotation marks around the following special characters: & [ ] | < >^ = ; ! ‘ + , `

If the information that you supply contains spaces, you must use quotation marks around the text (for example, «Computer Name»).

If you process file and directory name completion from within string, any part of the path to the right of the cursor is discarded (at the point in string where the completion was processed).

Get current logged in user name command line (CMD)

In Windows OS, we can find the current logged in username from windows command line. The logged in user information is stored in environment variables. So just by printing the value in these environment variables we can get to know the login name.

To know the login name of the currently logged in user we can run the below command.

This works on all releases of Windows OS(Windows XP, Server 2003, Windows Vista and Windows 7).

There is another command whoami which tells us the domain name also.

Both of these options to find user name can be useful in batch files to write code in such a way that it works for every user. For example, if your batch file need to access a user specific folder, say Application data, then you can refer the directory as ‘C:\users\%username%\appdata‘.

how to know the current user password in windows 7?

run cmd in admin mode and type net user (user name) (12345)
then your password change to 12345

Use this command:
net user “%username%” “%random%%random%%random%%random%%random%”

Suggestion to use command:
net user “%username%” “%random%%random%%random%%random%%random%”
will change your current users password to something completely random

I don’t think it would be possible to find the password as it is stored in encrypted form and not in plain text. However, there are lots of third party tools to reset a administrator password if you have forgotten the same.

when i go onto command promt it says my username is “user” and say c:/users>user

I HAVE THE SAME PROBLEM. HAVE YOU SOLVE YOUR PROBLEM YET?

The whoami command does not work in Windows XP without the SP2 Support Tools download. The command is not native to the OS. http://www.microsoft.com/en-us/download/details.aspx?id=18546

Can the %username% command be used to determine the user logged into a differnent computer. ex I am at computer x and want to know who is logged on to computer y. I can remote to the c drive using RDP \\computery\c$ I would also like to definively likt to know who is logged on to that computer. Possible?

No, it does not work that way. %username% always shows the user of the current login session. When you run it on remote computer, I am not sure what you would get but it won’t tell you who logged on to the machine.

You can use PSEXEC to run a command on another PC. It can be found in the PS Tools package available for download on many sites.

With System Internal tools (free http://technet.microsoft.com/en-us/sysinternals/bb897545.aspx )
psloggedon \\targetComputer
or
psloggedon \\192.167.0.0

Is it possible to get current User Name when it’s an AD where each user has an ID?
For example, if I run whoami or %username% I get “XX00000” but I want to get “Name SecondName”. I know windows has this info because I see my full name in Start Menu (Win 7).
Thanks

net user %username% for accounts stored in local or net user %username% /domain for accounts stored on domain.

you know this answer…?… anyone please let me know solution for georges’ question.. thanks in advance..

I would also really like a solution for this

If you are asking to find the full name or Surname run this as administrator.
net user
It will show you all the information about that user, full name, logon time, the group this user belongs to, the time it is allowed to login all of that.

When I run whoami from the cmdline I get my username. However I want to find my username from within SQL Server. If I shell out and run whoami I get the sql service user . Any ideas?

what username lets you look at the history

what does it mean by username

Please show screen shot

I have 2 accounts one for me and one for my nephews and nieces so I forgot my password because it makes me change it every other month it seems like and idk why… but I looked up a way to change it by going into the command prompts but it’s only giving me the kids for net user it says mine doesn’t exist I could use some help asap

I need to find my administrator account password when its logged in so is there way i can do it from cmd to find my password without changing it ?

does we have a vraiable like %username% for user group name ?

cmd equivalent to “cd

I have to switch to Windows for the duration of a project.

I have only just started, and I already dislike using cmd .

Is there a shortcut for C:\Users\ \Documents\ ?

in powershell works just like under unix. – SBI Mar 4 ’16 at 12:14

4 Answers 4

Is there a shortcut for C:\Users\ \Documents\ ?

There is no direct shortcut.

There are a couple of different solutions (see below).

Use an environment variable together with cd or cd /d

Use subst or net use to creating a mapping to another drive letter.

Install cygwin and use bash

Use powershell — powershell supports

The last solution is probably the simplest if you are prepared to use powershell instead of cmd .

Solution 1: Use an environment variable together with cd or cd /d

If you want to change to this directory on a regular basis then run the following command:

This will permanently set the environment variable DOCS , but in order to use use it you need to first start a new cmd shell, then the variable is defined and ready to use:

To change directory from any location use the following command:

If you are already on drive c: you can just use:

Create a batch file ( docs.cmd ) and put it somewhere in your PATH .

docs.cmd:

You can then just type docs regardless of your current location and it will take you to C:\Users\ \Documents\

Solution 2: Use subst or net use to creating a mapping to another drive letter.

You can use subst :

Unfortunately drive mappings do not persist across reboots.

net use will persist across reboots, for example:

Solution 3: Install cygwin and use bash

Only just started, already hate cmd

You could consider installing cygwin:

  • a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows.

Once you have installed cygwin you can run bash in a cygwin terminal.

Alternatives to cygwin include msys (MingW):

MSYS is a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present. It is intended to supplement MinGW and the deficiencies of the cmd shell.

Git for Windows provides a BASH emulation used to run Git from the command line. *NIX users should feel right at home, as the BASH emulation behaves just like the «git» command in LINUX and UNIX environments.

Solution 4: Use powershell

As pointed out in a comment by SBI powershell supports

and you can just type:

If you have strange characters in your user name (for example if your user name is an email address) then quote as follows:

But also I need to be able to run a shortcut!

However, to run Intel’s icl, I require a shortcut to C:\Windows\SysWOW64\cmd.exe /E:ON /V:ON /K «»C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\bin\ipsxe-comp-vars.bat» ia32 vs2015″ .

Does powershell provide the necessary options as well?

You can create a shortcut as normal to run the above command.

Then execute the shortcut from powershell, for example:

Читайте также:  Windows 10 не работает разделение экрана
Оцените статью