如何在 Windows 10 企业版上运行应用程序作为外壳替换
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33364908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run an application as shell replacement on Windows 10 Enterprise
提问by Jozef Legény
I need to create a special account on a computer running Windows 10 Enterprise. This account would launch an application directly on login instead of the default shell and exiting the application should force the computer to restart.
我需要在运行 Windows 10 Enterprise 的计算机上创建一个特殊帐户。此帐户将在登录时直接启动应用程序而不是默认 shell,退出应用程序应强制计算机重新启动。
I was able to do this easily on Windows 8.1 Embedded Industry Pro using the configuration console and lockdown features.
我能够使用配置控制台和锁定功能在 Windows 8.1 Embedded Industry Pro 上轻松完成此操作。
Now, on Windows 10 I try to follow the two tutorials on technet WESL_UserSettingand Set up a kiosk on Windows 10 Pro, Enterprise, or Education
现在,在 Windows 10 上,我尝试遵循 technet WESL_UserSetting和在 Windows 10 专业版、企业版或教育版上设置信息亭上的两个教程
However, neither of the tutorials work. I have managed to execute the scripts described in them but they have no effect (I've modified them so they do not remove the shells set).
但是,这两个教程都不起作用。我已经设法执行其中描述的脚本,但它们没有任何效果(我已经修改了它们,因此它们不会删除 shell 集)。
Finally I've ended up with the following code:
最后我得到了以下代码:
$COMPUTER = "localhost"
$NAMESPACE = "root\standardcimv2\embedded"
$ACCOUNT_NAME = "cmp"
$ShellLauncherClass = [wmiclass]"\$COMPUTER${NAMESPACE}:WESL_UserSetting"
$NTUserObject = New-Object System.Security.Principal.NTAccount($ACCOUNT_NAME)
$NTUserSID = $NTUserObject.Translate([System.Security.Principal.SecurityIdentifier]).Value
$NTUser_Shell = Get-WmiObject -namespace $NAMESPACE -computer $COMPUTER -class WESL_UserSetting |
where {$_.Sid -eq $NTUserSID}
if ($NTUser_Shell) {
"`Custom shell already set for [$ACCOUNT_NAME] removing it"
$ShellLauncherClass.RemoveCustomShell($NTUserSID)
}
$restart_shell = 0
$restart_device = 1
$shutdown_device = 2
$ShellLauncherClass.SetCustomShell($NTUserSID, "cmd.exe", ($null), ($null), $restart_device)
"`nCurrent settings for custom shells:"
Get-WmiObject -namespace $NAMESPACE -computer $COMPUTER -class WESL_UserSetting | Select Sid, Shell, DefaultAction
Executing this script in an admin powershell produces the desired output:
在管理 powershell 中执行此脚本会产生所需的输出:
Custom shell already set for [cmp] removing it
Current settings for custom shells:
Sid Shell DefaultAction
--- ----- -------------
S-1-5-21-3842421150-1098587697-2315725148-1002 cmd.exe 1
However logging as the 'cmp' user simply shows the standard Windows 10 shell.
但是,以“cmp”用户身份登录只会显示标准的 Windows 10 shell。
What should I change in order to be able to run a program instead of a standard shell?
为了能够运行程序而不是标准外壳,我应该更改什么?
采纳答案by kevmar
Have you tried changing the users shell?
您是否尝试过更改用户外壳?
https://msdn.microsoft.com/en-us/library/ms838576(v=WinEmbedded.5).aspx
https://msdn.microsoft.com/en-us/library/ms838576(v=WinEmbedded.5).aspx
There are a few registry keys you need to set. First one enables the ability to give the user a unique shell, the second one defines the executable that starts instead of explorer.
您需要设置一些注册表项。第一个能够为用户提供独特的 shell,第二个定义启动的可执行文件而不是资源管理器。
回答by Steven Spyrka
I had the same problem right now. And yes, Microsoft has changed the way to do a shell replacement. You can install and use the Embedded Shell Launcher to customize windows as you like it for kiosk mode. But this is only available for Enterprise and Education.
我现在遇到了同样的问题。是的,微软已经改变了进行外壳替换的方式。您可以安装和使用 Embedded Shell Launcher 来根据自己的喜好为 kiosk 模式自定义窗口。但这仅适用于企业和教育。
If you don't want to buy the Enterprise version you can use the already known registry locations in HKCU and HKLM. https://msdn.microsoft.com/en-us/library/ms838576(v=WinEmbedded.5).aspx
如果您不想购买企业版,您可以使用 HKCU 和 HKLM 中已知的注册表位置。https://msdn.microsoft.com/en-us/library/ms838576(v=WinEmbedded.5).aspx
But wait, oh no since Windows 10 it is only possible to use Microsoft signed applications, so your normal .net application isn't started and the screen keeps being black after login. But we've figured out a workaround.
但是等等,哦不,因为 Windows 10 只能使用 Microsoft 签名的应用程序,所以你的普通 .net 应用程序没有启动,并且在登录后屏幕一直是黑色的。但我们已经找到了解决方法。
Just use a Batch-File as bootstrapping. If you set the registry keys you like to a Batch-File and the Batch-File starts the real application, then it works like a charm.
只需使用批处理文件作为引导。如果您将喜欢的注册表项设置为批处理文件并且批处理文件启动了真正的应用程序,那么它就像一个魅力。
@echo off
echo Bootstrapping, please wait ...
start /b "Bootstrap" "C:\vmwatcher\VMViewClientWatcher.exe"
回答by Scott
I wanted to do something similar, and I borrowed heavily from other answers, but none of them were a complete working answer for me. Here's what I ended up doing.
我想做类似的事情,我从其他答案中大量借鉴,但对我来说,没有一个是完整的工作答案。这就是我最终做的。
- Create a new user account
- Setup the following vbs script (largely inspired by this thread) to launch the shell application and name it something like "launch.vbs"
- 创建一个新的用户帐户
- 设置以下 vbs 脚本(主要受此线程启发)以启动 shell 应用程序并将其命名为“launch.vbs”
set oShell=createobject("wscript.shell") sCmd="d:\launchbox\launchbox.exe" oShell.run sCmd,,true 'true forces it to wait for process to finish sCmd="shutdown /r /t 0" oShell.run sCmd
set oShell=createobject("wscript.shell") sCmd="d:\launchbox\launchbox.exe" oShell.run sCmd,,true 'true forces it to wait for process to finish sCmd="shutdown /r /t 0" oShell.run sCmd
Login as the new user
Run regedit
Add a new string value named Shell to HKEY_Current_User\Software\Microsoft\Windows NT\CurrentVersion\Winlogon with a value of the command that you need to run to execute your script:
以新用户身份登录
运行注册表
将名为 Shell 的新字符串值添加到 HKEY_Current_User\Software\Microsoft\Windows NT\CurrentVersion\Winlogon 中,并使用您需要运行以执行脚本的命令的值:
wscript d:\launchbox\launch.vbs
wscript d:\launchbox\launch.vbs
- Logoff and log back on as the user to see it in action
- 注销并以用户身份重新登录以查看其运行情况
回答by Michael
I battled with this one myself. If you look at the notes for Windows 10 Shell Launcher, it only works in the Enterprise or Education version. If you try using this in Home or Pro versions it simply boots to a blank screen. Using the same script in Enterprise, I confirmed works perfectly...
我自己和这个斗争过。如果您查看 Windows 10 Shell Launcher 的说明,它仅适用于企业版或教育版。如果您尝试在 Home 或 Pro 版本中使用它,它只会启动到一个空白屏幕。在企业中使用相同的脚本,我确认工作完美......
回答by Giovanni
I think you set up correctly the custom shell for the user, but maybe you need to activate the ShellLanuncher behaviour. Try this (at the end of your script):
我认为您为用户正确设置了自定义 shell,但也许您需要激活 ShellLauncher 行为。试试这个(在你的脚本末尾):
$ShellLauncherClass.SetEnabled($TRUE)
This way the standard windows 10 shell is not launched when you log on with the other account, but (at least in my case) the command line does not start and the result is a black screen.
这样,当您使用另一个帐户登录时,不会启动标准的 Windows 10 shell,但是(至少在我的情况下)命令行不会启动,结果是黑屏。
You can still run the task manager and run a new task from there, but I don't understand why the command line does not automatically start.
您仍然可以运行任务管理器并从那里运行新任务,但我不明白为什么命令行不会自动启动。
回答by FoxDeploy
I ran into the same issue, and that's because the Script from TechNet on how to configure ShellLauncheractually enables, then disables the same Shell!
我遇到了同样的问题,那是因为TechNet 中关于如何配置 ShellLauncher 的脚本实际上启用了,然后禁用了同一个 Shell!
# Enable Shell Launcher
$ShellLauncherClass.SetEnabled($TRUE)
$IsShellLauncherEnabled = $ShellLauncherClass.IsEnabled()
"`nEnabled is set to " + $IsShellLauncherEnabled.Enabled
# Remove the new custom shells.
$ShellLauncherClass.RemoveCustomShell($Admins_SID)
$ShellLauncherClass.RemoveCustomShell($Cashier_SID)
# Disable Shell Launcher
$ShellLauncherClass.SetEnabled($FALSE)
$IsShellLauncherEnabled = $ShellLauncherClass.IsEnabled()
"`nEnabled is set to " + $IsShellLauncherEnabled.Enabled
I was lazily just copying and pasting the code and expected it to work.
我只是懒洋洋地复制和粘贴代码,并希望它能够工作。
If you comment out the final ten lines, this process willwork.
如果您注释掉最后十行,则此过程将起作用。
Remember Kids: don't just copy and paste code from Strangers!
记住孩子们:不要只是复制和粘贴陌生人的代码!
回答by HeloDriver
My fist attempt to help where I have received much. Not a complete answer, but maybe enough to get you to your destination. This worked on my "Kiosk" app which is on "my" Windows 10 Enterprise system which was built specifically for my app. It will set your "shell" to start on system startup and then start your click once program. Hope this helps.
我的拳头试图帮助我收到很多的地方。不是一个完整的答案,但可能足以让您到达目的地。这适用于我的“Kiosk”应用程序,该应用程序位于“我的”Windows 10 Enterprise 系统上,该系统专为我的应用程序构建。它会将您的“shell”设置为在系统启动时启动,然后启动您的 click once 程序。希望这可以帮助。
Imports System.Threading
Public Class Form1
# Path to your ClickOnce app
Dim startPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Programs) _
& '"\"' & '"remaining path to your app"' & '".appref-ms"'
# Path to your shell which is also a clickonce app(this one)
Dim spath As String = Application.StartupPath & '"\"' & My.Application.Info.AssemblyName _
& '".exe"'
# This sets the registry to start your shell which in turn starts your app.
# I did this so that if the app is closed, they see the shell background.
# You can add controls to your shell to restart the app, shutdown....
#Just be cautious, make sure your app is 100% done and updates on it's own before you
# disable the ability to get back to windows explorer.
# Other wise you could have a very bad day.
My.Computer.Registry.SetValue('"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\ _
CurrentVersion\Winlogon"', '"Shell"', spath)
Thread.Sleep(500)
Process.Start(startPath)
End Class
回答by Johan A.
You can create a Provisioning Package using Windows Configuration Designer. The gui will help in creating a simple shell replacement when you choose 'provision kiosk devices'
您可以使用 Windows 配置设计器创建预配包。当您选择“提供信息亭设备”时,gui 将有助于创建一个简单的外壳替换