How to fix - The Command Prompt Has been Disabled by your Administrator - Without Access to an Administrator Account

Published: 9/25/2021
Updated: 11/13/2023

If you have ever used Windows in either a school or work environment and tried to open up the command prompt, chances are you've seen a screen that looks something like this:

This can be a real annoyance if you need to use the command prompt to check your IP Address, send a ping to troubleshoot your network connection, compile code, SSH into a server etc. The list of possible reasons why you would want, or need, to use the command prompt is virtually endless; but, regardless of what your reason to use the command prompt is, seeing this message can really put a rain on your parade.

The usual reason system administrators disable the command prompt is for "security reasons". However, sometimes they still let you have access to PowerShell which is by far the more dangerous of the two when it comes to security. You can do far more damage to a system with PowerShell than you ever could with the command prompt, since PowerShell is way more powerful than the command prompt.

Solutions that do not work

The only way around this is to get your system administrator to re-enable the command prompt for you. If you are in a school, good luck trying to get approval for that since it is never going to happen. In the workplace, again, good luck. You do have a better shot of getting your command prompt re-enabled in the work place if you can prove the command prompt is vital to your job. With that said, the process you may have to go through can still be a real chore, especially when you consider there may only be a slight chance of getting the command prompt back no matter how good your reasoning.

If you search online for "how to fix the command prompt has been disabled by your administrator" the results you will get require you to either modify registries or update group policies. Which, NEWS FLASH, standard users cannot do either of those things because they do not have admin access in order to perform those actions. If you have administrative access to the machine, then by all means go ahead and use one of those fixes and get the command prompt back, but for everyone else these "solutions" will not work.

The actual solution

One thing to keep in mind is that even though the command prompt is disabled, that does not necessarily mean you can't still run batch scripts. As a matter of fact, when system administrators go to disable the command prompt, batch files are still allowed to run by default. It is also unlikely that system administrators will even change this setting. This is because in most environments managed by system administrators, the system either has batch files running at logon, logoff, startup, and shutdown, and/or use remote desktop services, and Microsoft specificly says to not prevent the system from running batch scripts if either of these are the case. As you can see here:

It is in this fact where our solution lies. If you only use the command prompt to run a couple specific commands, you can just write a batch file with those commands and that will do the trick no problem. However, for those of us who want the full command prompt experience, we can exploit the fact that at the core of batch files is the command prompt. Since this is the case, we can use user input and batch script variables to give us a working command prompt that runs inside our batch file. The code for this batch file, that will give you a working command prompt, can be found and downloaded on my GitHub. With this solution, rather than running cmd.exe (which is disabled) when you need to use the command prompt, you instead run this batch file and you will have a working command prompt that you can use just like the real thing.

How it works

What this script is doing is running in an infinite loop of prompting you for input and then calling cmd.exe /c which runs the command you just typed. cmd.exe /c is able to execute the command by using a temporary command prompt environment inside your batch script. Once it finishes executing the command(s) you typed, the temporary environment stops, exits and then loops back to your batch file prompting you for your next command. By doing this, you no longer run into the issue of "the command prompt has been disabled by your administrator" by leaving the command prompt open like cmd.exe /k would do, or just straight up opening the command prompt. If you are interested, you can learn more about how the /c, /k and other flags work from Microsoft's documentation here.

Some of you out there might think there is an even simpler solution. "Why don't you just prompt the user for input, and then call that variable you stored the user input into? That would function just the same and be less code." That was actually my original solution, and it actually works great for everything you need to do. That is, of course, unless you need to do anything with variables like reference environment variables such as %windir%, %userprofile%, %programfiles%, %computername% etc. or create your own variables on the command prompt. Then this solution does not work. Which is why for this script, I went with using cmd.exe /c for maximum emulation to the real thing.

Drawbacks of this solution

Overall this script fully emulates the command prompt in all my testing aside from one minor issue. If you ever want to set variables on the command prompt, unfortunately, at this time you are unable to do so with this script. If you have any solutions to this issue then please reach out to me and let me know.

As of November 13, 2023, the script now has full support for setting and modifying environment variables. It does this by exporting the current environment variables when you launch the script, then reading them in and exporting them again before and after each command. That way, if you create or modify an environment variable, it will be exported and then re-imported for your next command.

Future improvements

As mentioned previously, if you have any solutions to fix the issue of being unable to set variables on the command prompt, please reach out to me. Also, the script currently relies on the use of an external files for keeping track of directory changes and environment variables because of the fact it uses a temporary command prompt environment to execute commands. Personally, I do not think this is the cleanest solution, but it works. If you have any recommendations to improve this, without losing any of the current functionality, I would also be eager to hear that as well.

Final thoughts

The command prompt is a great tool that can be used in a wide variety of ways. However, in certain environments like schools and workplaces, system administrators disable the use of the command prompt for "security reasons". The irony of this is, sometimes they still let users have access to the far more powerful and dangerous PowerShell. Current solutions on how to fix the issue of "the command prompt has been disabled by your administrator" rely on the fact that you have administrative privileges in order to fix it. These solutions simply do not work for standard non-administrative users just trying to use the command prompt.

This solution utilizes a batch script which can be run by all users, regardless of if they are an administrator or not, to allow them to have access to the command prompt. This batch script emulates the command prompt by exploiting the fact that at the core of batch files is the command prompt and uses user input, and batch script variables in order to subvert the administrative disabling of the command prompt. This gives non-administrator users access the command prompt who would otherwise not have the privilege level to re-enable the command prompt themselves.

If you are interested in downloading this batch script to be able to have access to the command prompt on a system in which your system administrator disabled the command prompt, you can download it here.