Execute from windows command prompt

How to Open Command Prompt

Open Command Prompt to Execute Commands in Windows 10, 8, 7, Vista, & XP

Some popular Command Prompt commands you might have heard of include ping, netstat, tracert, shutdown, and attrib, but there are many more. We have a complete list here.

While Command Prompt probably isn’t a tool most of you will use on a regular basis, it can really come in handy now and then, maybe to troubleshoot a specific Windows problem or to automate some kind of task.

How you open Command Prompt differs between Windows versions, so you’ll find steps below for Windows 10, Windows 8 or Windows 8.1, and Windows 7, Windows Vista, and Windows XP. See What Version of Windows Do I Have? if you’re not sure.

Open Command Prompt in Windows 10

Select the Start button.

Type cmd.

Select Command Prompt from the list.

Open Command Prompt Through the Start Menu

Another way to open Command Prompt in Windows 10 is to look in its Start menu folder:

Select the Start button.

Select the Windows System folder from the list.

Choose Command Prompt from the folder group.

Open Command Prompt Using Power User Menu

One more method in Windows 10 is through the Power User Menu. If you’re using a keyboard or mouse, choose Command Prompt from the menu that appears after pressing Win+X or right-clicking the Start button.

You might see Windows PowerShell options in the Power User Menu instead of Command Prompt. In more recent versions of Windows 10, Command Prompt has been replaced by PowerShell, but you can still access it from the Power User Menu by editing the taskbar settings.

Open Command Prompt in Windows 8 or 8.1

Select the Start button and then swipe up to show the Apps screen. You can accomplish the same thing with a mouse by selecting the down arrow icon at the bottom of the screen.

Prior to the Windows 8.1 update, the Apps screen can be accessed from the Start screen by swiping up from the bottom of the screen, or right-clicking anywhere, and then choosing All apps.

If you’re using a keyboard or mouse, a really quick way to open a Command Prompt window in Windows 8 is through the Power User Menu—just hold the WIN and X keys down together, or right-click the Start button, and choose Command Prompt.

Swipe or scroll to the right on the Apps screen to locate the Windows System section heading.

Select Command Prompt. You can now execute whatever command you needed to run.

See our List of Windows 8 Command Prompt Commands for a complete list of the commands available through Command Prompt in Windows 8, including short descriptions and links to more in-depth information if we have it.

Open Command Prompt in Windows 7, Vista, or XP

Open the Start menu from the bottom-left corner of the screen.

Читайте также:  Служба узла служба политики диагностики грузит диск windows 10

In Windows 7 and Windows Vista, it’s a bit faster to enter command in the search box at the bottom of the Start menu and then choose Command Prompt when it appears in the results.

Go to All Programs > Accessories.

Choose Command Prompt from the list of programs.

Here’s our List of Windows 7 Commands and List of Windows XP Commands if you need a command reference for any of those versions of Windows.

Other Ways to Open Command Prompt

Command Prompt in Windows XP through Windows 10 can also be opened with a command. This is especially helpful if you like using the Run dialog box or if Windows Explorer has crashed and the Start menu is inaccessible (and thus the directions above don’t work).

To do this, enter cmd into the command-line interface. This can be in the Run dialog box (WIN+R) or Task Manager’s File > Run new task menu.

Elevated Command Prompts and Old Windows Versions

In versions of Windows released before Windows XP, like Windows 98 and Windows 95, Command Prompt doesn’t exist. However, the older and very similar MS-DOS Prompt does. This program is located in the Start menu and can be opened with the command run command.

Some commands, like the sfc command that’s used to repair Windows files, require that Command Prompt be opened as an administrator before they can be executed. You’ll know if this is the case if you get a message like one of these after trying to execute the command:

  • check that you have administrative rights
  • . command can only be executed from an elevated command prompt
  • you must be an administrator

See How to Open an Elevated Command Prompt for help starting Command Prompt as an administrator, a process that’s a bit more complicated than what’s outlined above.

How to Open an Elevated Command Prompt

Open Command Prompt as an administrator in Windows 10, 8, 7, & Vista

Some commands available in Windows require that you run them from an elevated Command Prompt. Basically, this means running the Command Prompt program (cmd.exe) with administrator-level privileges.

When Do You Need an Elevated Command Prompt?

You’ll know if you need to run a particular command from within an elevated Command Prompt because it’ll clearly tell you that in an error message after running the command.

For example, when you try to execute the sfc command from a normal Command Prompt window, you’ll get the «You must be an administrator running a console session in order to use the sfc utility» message.

Try the chkdsk command and you’ll get an «Access Denied as you do not have sufficient privileges or the disk may be locked by another process. You have to invoke this utility running in elevated mode and make sure the disk is unlocked» error.

Other commands give other messages, but regardless of how the message is phrased, or what Command Prompt command we’re talking about, the solution is simple: open an elevated Command Prompt and execute the command again.

Time Required: Opening an elevated Command Prompt will take most of you under a minute from start to finish. Once you know how to do it, you’ll be even faster the next time.

The specific steps involved in opening an elevated Command Prompt differ somewhat depending on your operating system. The first tutorial works for Windows 10 and Windows 8, and the second for Windows 7 and Windows Vista. See What Version of Windows Do I Have? if you’re not sure.

How to Open an Elevated Command Prompt in Windows 10 or Windows 8

The following process only works for Windows 10 and Windows 8, which is unfortunate since it’s super-simple and works for elevating other programs as well, not just Command Prompt.

If you’re using a keyboard with Windows 10 or Windows 8, you can open an elevated Command Prompt quickly from the Power User Menu. Just use the WIN+X keyboard shortcut and then select Command Prompt (Admin). Choose Yes on any User Account Control messages that might appear.

Читайте также:  Windows те option pack

Depending on your settings and Windows configuration, Command Prompt may be replaced by Windows Powershell.

Open Task Manager. The quickest way, assuming you’re using a keyboard, is via CTRL+SHIFT+ESC but there are several other methods outlined in that link. One easy way is to type the app name into Cortana’s search field.

Go to File > Run new task.

Don’t see the File menu? You may first have to select More details at the bottom of the Task Manager window to show a more advanced view of the program, including the File menu.

In the Create new task window you see now, type the following in the Open text field:

cmd

. but don’t do anything else just yet!

Check the Create this task with administrative privileges. box.

Don’t see this box? That means that your Windows account is a standard account, not an administrator account. Your account must have administrator privileges to be able to open an elevated Command Prompt this way. Follow the Windows 7/Vista method below, or try the tip just below these instructions.

Choose OK and then follow any User Account Control requirements that might appear next.

An elevated Command Prompt window will now appear, allowing unrestricted access to executing commands.

Feel free to close Task Manager. It does not need to remain open to use Command Prompt.

If you’re using a keyboard with Windows 10 or Windows 8, you can open an elevated Command Prompt quickly from the Power User Menu. Just use the WIN+X keyboard shortcut and then select Command Prompt (Admin). Choose Yes on any User Account Control messages that might appear.

How to Open an Elevated Command Prompt in Windows 7 or Vista

Locate the Command Prompt shortcut, usually in the Accessories folder in the Start Menu.

If you’re having trouble finding it, see How to Open Command Prompt (the non-elevated kind). But first, there’s an intermediate step you need to take.

Right-click it and choose Run as administrator.

Accept any User Account Control messages or warnings.

An elevated Command Prompt window should appear, allowing access to commands that require administrative level privileges.

More About Elevated Command Prompts

Don’t let all the discussion above convince you that you should, or need to, run Command Prompt as an administrator for most commands. For almost all Command Prompt commands, no matter what version of Windows, it’s perfectly okay to execute them from a standard Command Prompt window.

To be able to open an elevated Command Prompt window, either a) your Windows user account must already have administrator privileges, or b) you must know the password to another account on the computer that has administrator privileges. Most home computer user’s accounts are set up as administrator accounts, so this isn’t usually a concern.

How to Tell if You Have Administrator Privileges

There’s a very easy way to tell if the Command Prompt window you’ve opened is elevated or not: it’s elevated if the window title says Administrator; it’s not elevated if the window title just says Command Prompt.

An elevated Command Prompt window opens to the system32 folder. A non-elevated Command Prompt window instead opens to the user’s folder: C:\Users\[username].

If you plan on frequently using an elevated Command Prompt then you should consider creating a new shortcut to Command Prompt that automatically starts the program with administrator-level access. See How to Create an Elevated Command Prompt Shortcut if you need help.

In Windows XP, users have Administrator privileges by default. When you open a Command Prompt in XP it will be elevated unless you have another type of profile.

Читайте также:  Logiciel windows 10 gratuit

Automatically executing commands when a command-prompt is opened

I am looking for a way to execute some console commands automatically when a command-prompt is opened in Windows, specifically to set some command aliases.

For example, when a command-prompt is opened, I want a command such as the following to be automatically run so that I can use ls instead of dir .

How can this be done?

6 Answers 6

If you want it to load on bootup, rather than when you log in, if you have XP Pro (XP home does not include gpedit.msc), do this:

and hit enter. Then run gpupdate /force from a command line.

Computer Configuration>Windows Settings>Scripts>Startup

and add the location to the script.

You can also do this for a user logon under

User Configuration>Windows Settings>Scripts>Startup

If you have XP Home, you can copy the scripts to either:

for loading them on bootup, or:

for loading them for a user on logon. The GroupPolicy folder is hidden.

Command aliases are specific to the console window you configure them on, therefore a startup script will not work. You can do it this way:

Create a batch file ( .cmd ) with your doskey commands, put it somewhere in Application Data.

Configure it to be started automatically whenever you open cmd. The setting is in Registry:

  • key: HKCU\SOFTWARE\Microsoft\Command Processor
  • value: AutoRun
  • type: REG_EXPAND_SZ
  • data: «%AppData%\aliases.cmd»

Different command interpreters handle command aliases in different ways.

Microsoft’s CMD relies upon the Win32 console subsystem to provide its command aliasing mechanism. The doskey command actually interacts with the process’ console, and it is the console itself that holds aliases. Thus aliases are per-console and transient.

JP Software’s TCC/LE handles aliases itself. The alias command allows one to view and manipulate aliases, which are either «local» or «global». Aliases are still transient, but are either private to one command interpreter process or shared amongst all command interpreter processes (across all consoles).

Shells such as the Korn shell in the SFUA utility toolkit — whose tools run in the Subsystem for UNIX-based Applications that comes right there in the box with Windows 7 Ultimate edition and Windows Server 2008 R2 (For Windows XP, one can download and install Services for UNIX version 3.5.) — and the Bourne Again shell from cygwin similarly handle aliases themselves. Aliases are transient, and per command interpreter process.

Auto-loading a default initial set of aliases varies by command interpreter, too.

In all cases, one places commands to set the aliases in a script of some sort.

grawity has already given one of the two registry keys that cause Microsoft’s CMD to run a command as it starts up. Unfortunately, this is per command interpreter process, even though the aliases themselves are stored per console. Start a secondary command interpreter from the initial one, and any manual changes to the default aliases will be reset. An alternative, that at least performs initialization only once per console, is to add the /K option and the name of a command script that calls doskey to the command tail in the shortcut that starts the command interpreter.

JP Software’s TCC/LE automatically runs the TCSTART script upon its startup. Again, this is per command interpreter process. However, TCC’s «local» aliases are also per command interpreter process, so this is the right place to initialize aliases if one is employing local aliases. For global aliases, simply create a shortcut in your Startup folder that loads aliases from a file (with alias /r ) and then runs the shralias command so that they persist after that shortcut has finished running.

For the Bourne Again and Korn shells, simply do as one would with these shells on any other platform. Use the alias command in the $HOME/.profile and $HOME/.bashrc scripts for the Bourne Again shell; and use the alias command in the $HOME/.profile , ENV, and $HOME/.kshrc scripts for the Korn shell.

Оцените статью