gpt4 book ai didi

c# - 在 Windows 7 上安装 C# Windows 服务

转载 作者:太空狗 更新时间:2023-10-29 19:52:45 25 4
gpt4 key购买 nike

我有一个批处理文件,我一直使用它来安装我的 C# Windows 服务,直到 Windows 7 才出现问题。我试图以管理员权限运行该批处理文件。我试图使用管理员权限运行命令提示符,导航到 Windows 服务 EXE 并在那里运行 InstallUtil。还是不行。

在阅读了一些其他建议后,我尝试将我的文件移出/bin 文件夹并从另一个位置运行它们,但这也没有用。

批处理文件如下所示

@ECHO OFF

REM The following directory is for .NET 2.0
set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727
set PATH=%PATH%;%DOTNETFX2%

echo Installing IEPPAMS Win Service...
echo ---------------------------------------------------
InstallUtil /i IEPPAMS_WinService1.exe
echo ---------------------------------------------------
echo Done.

我有一个安装日志文件,我将信息转储到其中。如果我只是双击我得到的 .bat 文件

Running a transacted installation.

Beginning the Install phase of the installation. See the contents of the log file for the C:\Users\Justin\Desktop\service test\IEPPAMS_WinService1.exe assembly's progress. The file is located at C:\Users\Justin\Desktop\service test\IEPPAMS_WinService1.InstallLog.

An exception occurred during the Install phase. System.InvalidOperationException: Cannot open Service Control Manager on computer '.'. This operation might require other privileges. The inner exception System.ComponentModel.Win32Exception was thrown with the following error message: Access is denied.

The Rollback phase of the installation is beginning. See the contents of the log file for the C:\Users\Justin\Desktop\service test\IEPPAMS_WinService1.exe assembly's progress. The file is located at C:\Users\Justin\Desktop\service test\IEPPAMS_WinService1.InstallLog.

The Rollback phase completed successfully.

The transacted install has completed.

当我以管理员权限运行 .bat 文件时,日志文件中没有任何内容,而且服务仍未安装。

有什么想法吗?有没有一种在 Windows 7 中安装服务的新方法?

最佳答案

右键单击批处理文件并以管理员身份运行。

您很可能会遇到来自 Windows Vista 和 Windows 7 的新安全模型(用户帐户控制)。即使您以具有管理员权限的帐户运行,您仍然需要提升权限才能执行某些操作(大多数) 行政事件。 (是的,可以禁用此功能,但不要这样做)

编辑... 正确的命令行是 InstallUtil YourApp.exe/i 看起来不是 InstallUtil 的有效开关。

关于c# - 在 Windows 7 上安装 C# Windows 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3612210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com