【发布时间】:2014-09-28 16:15:37
【问题描述】:
我正在尝试使用不同的用户(而不是服务用户)从 C# 服务运行带有 System.Diagnostics.Process 的 djoin.exe 工具。
进程返回代码-1073741502。
在事件日志中我可以看到:
应用程序弹出窗口:djoin.exe - 应用程序错误:应用程序是 无法正确启动 (0xc0000142)。点击确定关闭 应用。
没有标准错误或标准输出。
这是我使用的流程配置:
ProcessStartInfo startInfo = new ProcessStartInfo
{
Arguments = "/Provision /Domain domain.com /Machine PC12 /SaveFile NUL /printblob",
WorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
FileName = "djoin.exe"
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardInput = true,
RedirectStandardOutput = true,
CreateNoWindow =true,
Domain = "domain.com",
UserName = "other-user",
Password = "***"
};
if (username!=null)
{
startInfo.Domain = domain;
startInfo.UserName = username;
startInfo.Password = ToSecureString(password);
}
p = new Process { StartInfo = startInfo };
p.Start();
使用RUNAS 命令时,一切正常。
有什么问题?
【问题讨论】:
-
这是什么版本的 Windows?而且,您的应用是否具有提升的权限?
-
Windows 2008 服务器 R2。这是一项服务。什么是提升权限?
-
该程序使用的其中一个 DLL 的 DllMain() 入口点返回 FALSE。很不高兴,你真的不知道为什么,除非它在应用程序事件日志中留下了一条消息。你会找到一个的可能性不大。尽管您绝对应该尝试将 LoadUserProfile 设置为 true,但您没有足够的旋钮来调整。请联系应用的作者或所有者寻求帮助。
-
@HansPassant djoin 似乎是标准的“内置”实用程序,是 Windows Server technet.microsoft.com/en-us/library/ff793312.aspx的一部分@
标签: c# .net impersonation