如何访问/什么是SYSTEM帐户下Windows服务的WiX CommonAppDataFolder参数 [英] How to access/What is the the WiX CommonAppDataFolder Parameter for a Windows Service under SYSTEM Account

查看:69
本文介绍了如何访问/什么是SYSTEM帐户下Windows服务的WiX CommonAppDataFolder参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows服务,该服务需要在SYSTEM帐户下运行.我使用CommonAppDataFolder作为特定于应用程序的配置内容和源材料(例如日志文件,Excel模板文件等)的目的地.该服务可以正确安装并运行,但是在尝试加载Excel模板文件时遇到问题,以下内容表明该服务能够访问和写入日志文件.该应用程序使用NLog作为日志记录框架:

I have a Windows Service which needs to run under the SYSTEM account. I am using the CommonAppDataFolder as the destination for application specific configuration content and source material such as log files, Excel template files etc... The Service installs correctly and runs, however when it attempts to load the Excel template file it encounters a problem, the following content shows that the service is able to access and write to the log file. The application is using NLog as the Logging Framework:

应用程序名称:AppName文件版本:5.2.0.0发布:用户:NT AUTHORITY \ SYSTEM| 12:24:59 | NT AUTHORITY \ SYSTEM | Info | AppName-已启动的AppName服务2 | 12:24:59 | NT AUTHORITY \ SYSTEM | Trace | AppName-从配置文件中获取RTU警报名称3 | 12:24:59 | NT AUTHORITY \ SYSTEM | Trace | AppName-从配置文件中获取条件警报名称4 | 12:25:23 | NT AUTHORITY \ SYSTEM | Debug | AppName-获取预定的查询

Application Name: AppName File Version: 5.2.0.0 Released: User: NT AUTHORITY\SYSTEM |12:24:59|NT AUTHORITY\SYSTEM|Info|AppName - Started AppName Service 2|12:24:59|NT AUTHORITY\SYSTEM|Trace|AppName - Fetching RTU alarm names from configuration file 3|12:24:59|NT AUTHORITY\SYSTEM|Trace|AppName - Fetching conditonal alarm names from configuration file 4|12:25:23|NT AUTHORITY\SYSTEM|Debug|AppName - Fetched scheduled queries

日志文件位于:

D:\ programdata \ Companyname \ AppName \ Logs

D:\programdata\Companyname\AppName\Logs

但是,当服务尝试访问Excel模板文件时,它会生成:

However when the service attempts to access the Excel template file it generates:

System.Runtime.InteropServices.COMException(0x800A03EC):Microsoft Excel无法访问文件"d:\ programdata \ CompanyName \ AppName \ Templates \ PsaDefault.xltm".有几种可能的原因:

System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Excel cannot access the file 'd:\programdata\CompanyName\AppName\Templates\PsaDefault.xltm'. There are several possible reasons:

•文件名或路径不存在.

• The file name or path does not exist.

•该文件正在被另一个程序使用.

• The file is being used by another program.

•您要保存的工作簿与当前打开的工作簿具有相同的名称.

• The workbook you are trying to save has the same name as a currently open workbook.

这些都不是原因.此后,我立即想到的是,好吧... SYSTEM帐户的commonappdata位于不同的位置,并且对此问题进行了快速的搜索.但是,如果是这种情况,服务将如何写入和访问完全相同的文件夹结构下的日志文件?

None of these is the cause. My immediate thought thereafter was, Ok... commonappdata for SYSTEM account is in a different location, and this was bourne out with a quick google on the subject. However if this is the case how is the service able to write to and access the log file, which is under exactly the same folder structure?

有没有一种方法可以修改我的WiX项目,以提供必要的说明来覆盖可能的已登录用户"/SYSTEM帐户冲突,或者将文件夹结构更改为SYSTEM帐户不会遇到此问题的位置.SYSTEM帐户是否具有等效的WiX参数?还是我对这个问题的假设完全错了?

Is there a way that I can amend my WiX project to either provide the necessary instructions to override possible 'Logged in User'/SYSTEM account conflicts, or alternatively change the folder structure to a location where the SYSTEM account does not encounter this issue. Is there an equivalent WiX parameter for the SYSTEM account? Or am I completely wrong in my assumptions with respect to this problem?

以下是我的product.wxs文件的摘录(GUID,公司和应用程序特定的信息已被占位符覆盖):

The following is an excerpt from my product.wxs file (GUIDs, Company and Application specific info overwritten with placeholders):

  <!-- The following section deals with the deployment of the application data files including logs, templates and userguide elements-->
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="CommonAppDataFolder" Name="CommonAppData" >
      <Directory Id="dirCompanyAppData" Name="CompanyName">
        <Directory Id="dirAppNameAppData" Name="AppName">
          <Component Id="cmpDirAppNameAppData" Guid="{###}" KeyPath="yes">
            <CreateFolder Directory="dirAppNameAppData" />
            <RemoveFile Id="PurgeAppnameAppData" Name="*.*" On="uninstall" />
            <RemoveFolder Id="idDirAppNameAppData" On="uninstall" Directory="dirAppNameAppData" />
          </Component>
          <Directory Id="dirAppNameAppDataOutput" Name="Output">
            <Component Id="cmpDirAppNameAppDataOutput" Guid="{###}">
              <CreateFolder Directory="dirAppNameAppDataOutput" />
              <RemoveFile Id="PurgeAppNameAppDataOutput" Name="*.*" On="uninstall" />
              <RemoveFolder Id="idDirAppNameAppDataOutputRemove" On="uninstall" Directory="dirAppNameAppDataOutput" />
            </Component>
          </Directory>

推荐答案

建议 :简而言之,将模板移至以下位置: %ALLUSERSPROFILE% .

Suggestion: In short, move template to somewhere under: %ALLUSERSPROFILE%.


文件/文件夹ACL :用户的实际ACL设置配置文件文件夹本身可能是原因.你能跑吗从 %ALLUSERSPROFILE% 下的某个地方?默认情况下应该可写吗?

File / Folder ACL: The actual ACL settings on the user profile folder itself could be the cause. Could you try to run from somewhere under %ALLUSERSPROFILE%? Should be writable by default?

在现代Windows系统上,通常映射到: C:\ ProgramData (在其他地方的旧系统上).我认为 SYSTEM 帐户应该在此处具有完全访问权限?试试吧?

On modern Windows systems that usually maps to: C:\ProgramData (on older systems somewhere else). I think the SYSTEM account should have full access here? Give it a go?


测试路径 :要测试该路径: Windows键 +点击 R .粘贴 %ALLUSERSPROFILE% ,然后按 OK .

也:打开 cmd.exe 并转到" 设置 "(不带引号)以查看环境变量及其值.会有所帮助.只是为了方便而添加(众所周知).

Also: Open a cmd.exe and go "set" (without the quotes) to see environment variables and their values. Can be helpful. Just adding for convenience (it is well-known).


DCOM权限 :COM服务器具有关联的启动权限.一些工具和注释可帮助您进行调试:


DCOM Permissions: COM servers have associated permissions for launching. Some tools and comments to help you debug:

  • 默认 :在 comexp.msc DCOM 权限.> .

  • 启动: Windows键 +点击 R .粘贴 comexp.msc ,然后按 OK .
  • 右键单击我的电脑 => 属性 => COM-Security .
  • 我对这些设置没有太多关注.灵活多变,有意义的几件事?
  • Launch: Windows Key + Tap R. Paste comexp.msc and press OK.
  • Right click My Computer => Properties => COM-Security.
  • I haven't looked much at these settings. A lot of flexibilty, few things that make sense?

特定 :注册表中还可以为每个COM类设置特定的权限.也许使用 oleview.exe (或直接使用 regedit.exe )进行检查?

  • 在Windows SDK文件夹中找到 oleview.exe .在以下磁盘中搜索磁盘: %ProgramFiles(X86)%\ Windows Kits \ [SDK-VERSION-NUMBER-HERE] \ bin .
  • 找到您的班级(以下示例: Scripting.Dictionary ).请参见 启动权限" 访问权限" 标签.

我不记得在这里看到过许多针对Office应用程序的自定义设置,我可能是错的.我目前没有Office要测试.

I can't recall having seen many custom settings here for Office apps, I could be wrong. I don't have Office to test with at the moment.

这篇关于如何访问/什么是SYSTEM帐户下Windows服务的WiX CommonAppDataFolder参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆