我为此苦苦挣扎,而这篇文章是如此接近。在尝试了一些其他的事情之后,我知道这篇文章很接近了,我想尝试一下。
作为记录,当我们运行 Windows Server 2008 R2 和 Excel 2013 自动化时,systemprofile 中的“桌面”文件夹修复修复了这个问题。这只是在我们升级到 Windows Server 2012 R2 和 Excel 2016 后才开始出现的问题。为了消除 Excel 作为罪魁祸首,我在装有 Windows Server 2012 R2 和 Excel 2013 的服务器上进行了尝试,并遇到了非常相似的问题。
所有自动化在 Network Service 下运行良好,但理想情况下,我们希望在 ApplicationPoolIdentity 下运行我们的网站。
首先,使用 ApplicationPoolIdentity 运行的应用程序池需要加载用户配置文件。
Start Run -> inetmgr
expand Server -> Application Pools
right click on your App Pool -> Advanced Settings
under Process Model -> Load User Profile <-- should be set to true
所以现在我必须弄清楚这个身份是谁。也许有更好的方法可以做到这一点,但由于我将用户添加到 IIS_IUSRS,因此我在此处找到了信息。
Windows -> Edit local users and groups
Groups -> right click IIS_IUSRS -> Add to Group...
Add...
Locations... (choose local server), click OK
In the Enter the object names to select box type IIS APPPOOL\<app pool name>
(note the space and the triple P)
also, <app pool name> is the name of your Application Pool in inetmgr
现在您应该将其视为 IIS_IUSRS IIS APPPOOL\ (SID) 的成员,其中 SID 是您在 Windows 中的 applicationpoolidentity 安全标识符。这将是一个很长的字母数字虚线字符串,例如 "S-1-5-##-#########-#########-######## ##-#########-#########"
与上面的答案不同,这是我需要在注册表中编辑的用户。
所以现在按照上述答案,我必须将以下内容添加到注册表中。注意:将密钥添加到 S-1-5-18 并不能解决问题,我必须将它们添加到上面找到的 ApplicationPoolIdentity 的 SID。
[HKU]\SID\Software\Microsoft\Windows NT\CurrentVersion\Devices
"Send To OneNote 2010"="winspool,nul:"
"Microsoft XPS Document Writer"="winspool,Ne00:"
[HKU]\SID\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts
"Send To OneNote 2010"="winspool,nul:,15,45"
"Microsoft XPS Document Writer"="winspool,Ne00:,15,45"
[HKU]\SID\Software\Microsoft\Windows NT\CurrentVersion\Windows
"UserSelectedDefault"=dword:00000000
"Device"="Microsoft XPS Document Writer,winspool,Ne00:"
请注意我是如何使用 eletre/Robert 的“正确”响应的。对设备使用 OneNote 选项对我不起作用。
希望这可以省去某天追捕这个问题的麻烦。