7.13 如何切换到"Session 0" https://scz.617.cn/windows/200704270000.txt A: 关于"Session 0",参看: -------------------------------------------------------------------------- Application Compatibility Session 0 Isolation - [2007-04-27] https://blogs.technet.microsoft.com/askperf/2007/04/27/application-compatibility-session-0-isolation/ Inside Session 0 Isolation and the UI Detection Service Part 1 - Alex Ionescu [2008-03-15] http://www.alex-ionescu.com/?p=59 Inside Session 0 Isolation and the UI Detection Service Part 2 - Alex Ionescu [2008-03-28] http://www.alex-ionescu.com/?p=60 -------------------------------------------------------------------------- sc qc UI0Detect sc query UI0Detect sc start UI0Detect 确保UI0Detect服务运行中 sc create session0cmd binpath= "cmd.exe /c start" type= own type= interact sc start session0cmd 此时会弹出"交互式服务检测"对话框,点击其上的"查看消息",就会从"Session 1" 切换到"Session 0",后者桌面上已经有一个cmd,当前帐号是: $ whoami nt authority\system "Session 0"的桌面上也有个"交互式服务检测"对话框,点击其上的"立即返回",将 切回"Session 1"。 可以命令行切换Session: rundll32 winsta.dll,WinStationSwitchToServicesSession // 切至"Session 0" rundll32 winsta.dll,WinStationRevertFromServicesSession // 返回"Session 1" 命令行这个,没有实际意义,效果与"交互式服务检测"对话框一样,二者都依赖 UI0Detect服务。如果UI0Detect未启动,没有"交互式服务检测"对话框,命令行切换 没有反应。 在"Session 0"里Ctrl-Shift-Esc呼不出任务管理器,因此必须提前用sc启动一个cmd, 否则啥也干不了。也可以提前用sc启动一个explorer: sc create session0explorer binpath= "cmd.exe /c start explorer.exe" type= own type= interact sc start session0explorer 可以用sysinternals的工具: psexec.exe -s -i 0 cmd.exe 它会自动启动UI0Detect服务。 Q: 在x64/Win10上启动UI0Detect服务,总是自动停止,怎么回事? A: -------------------------------------------------------------------------- Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows] "NoInteractiveServices"=dword:00000000 -------------------------------------------------------------------------- reg add "HKLM\SYSTEM\CurrentControlSet\Control\Windows" /v "NoInteractiveServices" /t REG_DWORD /d 0 /f reg query "HKLM\SYSTEM\CurrentControlSet\Control\Windows" /v "NoInteractiveServices" 该值缺省为1,将之改为0,重启OS使之生效,然后在Win10上可以正常启动UI0Detect 服务。 不知是Win10本身的问题,还是VMware的问题,切至"Session 0"之后,cmd确实在那 儿,但键盘、鼠标无效。Win7不存在这个问题。 Q: 如何检查一个进程属于哪个Session? A: scz OS自带命令查看"Session 0"中的进程: qprocess /id:0 qprocess /id:0 | findstr cmd qprocess cmd.exe | findstr system qprocess system | findstr cmd A: bluerust 2018-04-11 Process Explorer,右键查看指定进程属性,在Security标签页有Session、 Logon Session这两项。 $ wmic process where name="cmd.exe" get executablepath,processid,commandline,sessionid CommandLine ExecutablePath ProcessId SessionId "C:\Windows\System32\cmd.exe" C:\Windows\System32\cmd.exe 2408 1 "cmd.exe" C:\Windows\system32\cmd.exe 1760 0 "C:\Windows\System32\cmd.exe" C:\Windows\System32\cmd.exe 1816 1 $ wmic process where processid=1760 get name,processid,commandline,sessionid CommandLine Name ProcessId SessionId "cmd.exe" cmd.exe 1760 0 $ wmic process where sessionid=0 get name,processid $ wmic process where "name='cmd.exe' and sessionid=0" get processid,commandline CommandLine ProcessId "cmd.exe" 1760 $ powershell -c "Get-Process | Format-Table ProcessName,Id,SessionId" $ powershell -c "Get-Process -Name cmd | Format-Table ProcessName,Id,SessionId" $ powershell -c "Get-Process -Name cmd* | Format-Table ProcessName,Id,SessionId" $ powershell -c "Get-Process -Id 1760 | Format-Table ProcessName,Id,SessionId" ProcessName Id SessionId ----------- -- --------- cmd 1760 0 powershell显示的进程名不带扩展名,是个坑。