I'm trying to launch cmd.exe in session 0. So far I've done the following from an elevated command prompt:

sc config UI0Detect start= auto
net start UI0Detect

And the response indicates that the service was started correctly. It is at this point that I assumed if I switched to session 0, cmd.exe would be running.

I switch to session 0 using the following command:

rundll32 winsta.dll,WinStationSwitchToServicesSession

This successfully switches me to session 0, but the only window that's available is the one that has the option to return to session 1.

How do I get cmd.exe to launch in session 0?

  • Why would you want to do this? UI0Detect allows old services to pop up a message box, not starting new GUI Apps. cmd.exe has a GUI May 21, 2012 at 4:56
  • 7
    @PeterHahndorf I understand that it's fun to deflect answering questions by saying "let's take a step back and see if this is what we really need to do because this sounds like a bad idea", and it's a relatively nice way to condescend fellow developers. But since this is for a debugging scenario and meant to be a quick fix (and alternative to using some 3rd party app like AlwaysUp), I don't really see how asking "why" is a helpful response. Thanks anyway.
    – omghai2u
    May 21, 2012 at 5:12
  • I think Peter has a point. The question you should have wrote is "This is what I'm trying to do." A quick fix will only involve future pain. I can't count how many times I've heard "quick fix" only to still see the "quick fix" in production three years later. . . needing another "quick fix". I'm assuming you are typing to run a batch script of some sort?
    – surfasb
    May 21, 2012 at 8:54
  • 2
    @surfasb The question you suggested is essentially the question I wrote: "I'm trying to launch cmd.exe in session 0." Please keep answers focused on that question. Thanks. And there's no chance this will make its way into production, or for it to involve future pain. The way I do it for production is already set but I can't use it for debugging. The way I currently do it for debugging is cumbersome and involves using a 3rd party app.
    – omghai2u
    May 21, 2012 at 19:20

4 Answers 4


To launch cmd.exe in session 0, use psexec from Sysinternals

psexec.exe -s 0 cmd.exe

Now you have a console running in session 0,

you can also start cmd.exe in session 0 and display GUI:

psexec.exe -s -i 0 cmd.exe

that way when you switch to session 0, the cmd.exe will be waiting for you there.

you have as many rights as you can get in Windows 7:

whoami /all

if you use other PsTools, remember to use the /accepteula switch:

pslist /accepteula

otherwise the program pops up a message box to ask to accept the Eula, the program will hang because there is no UI in session 0 to close the message box.

To verify that you are running in session 0, you can use qprocess:

qprocess /ID:0

you will see your 'cmd.exe' among all the service processes.

  • Awesome thanks for attempting to answer my question. This would certainly work, my specific intention (as pointed out in the comments), however was to avoid using 3rd party apps. Is there a nice way to do this that doesn't necessitate the use of SysInternals tools (or really anything that doesn't come stock on Windows)? Thanks again.
    – omghai2u
    May 23, 2012 at 23:58
  • 2
    I don't consider the Sysinternal tools '3rd party' they are from Microsoft and you don't have to install them. May 24, 2012 at 5:15
  • Sorry, I was considering anything not installed by default "3rd-party".
    – omghai2u
    May 27, 2012 at 23:47
  • Peter. Awesome, thank you. Works perfectly for starting a process in session 0 (which means it keeps running when you log off.) Oct 22, 2013 at 1:51
  • 6
    The first command line is wrong: -s runs as SYSTEM user and doesn't take an argument. Perhaps you meant -i 0 in the first example and -s -i 0 in the second one?
    – jwg
    Mar 5, 2014 at 9:46

It won't work. It merely starts a process as System.

Services are programs written in a special way to accept commands from the service control manager.

MS has a utility that allows running a program as a service. It's called Srvany and is in the Windows 2003 Resource Kit Tools.

Download Windows Server 2003 Resource Kit Tools


I discovered the solution by accident one day, but http://www.alex-ionescu.com/?p=59 also documents a solution near to what I found

Create a batch file with the following (call it some.bat)

start cmd

Then create a service to call this batch file (using an Admin Command Prompt)

sc create access0 type= interact type= own binpath= some.bat

(Note the space after each =, and I suggest using full path for some.bat)

Then it is a matter of starting the services

sc start ui0detect
sc start access0

(There is no need to make ui0detect auto start with sc config UI0Detect start= auto)

And if all goes well, you will get the flashing box of imminent messages! Go to View Messages and you will have yourself an Admininstrator (nt authority\system) Command Prompt that will not be auto destroyed by a failed service start (hence the need for a batch file with the start command)

This does work, although sometimes it doesn't work the first try.

I believe this gives you access to the interactive session 0 only, which only exists for the nt authority\system user


You can use the shortcut start(Windows)+R to start the 'run' dialog. From there, just type 'cmd' (no quotes) and voila. cmd

  • 4
    Welcome to SuperUser. Your post does not answer the OPs question. Starting CMD normally does not put one into Session 0. Jan 1, 2015 at 23:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .