使用特定用户名从系统帐户启动进程
我正在 C#.net
中开发 Windows 服务,帐户:LocalSystem
,系统:Windows XP SP3
我希望此服务检查所有当前登录的用户是否正在运行特定应用程序,如果没有运行,则以相应的用户名启动此应用程序。
我提供了域名、名称、密码,但 Start() 抛出 Win32Exception 异常“访问被拒绝”
process.StartInfo.Domain = domain;
process.StartInfo.UserName = name;
process.StartInfo.Password = password;
process.StartInfo.FileName = fileName;
process.StartInfo.UseShellExecute = false;
process.Start();
我提供的凭据的用户位于管理员组中 - 如果手动启动,应用程序将成功运行。
这是通过不同的方式完成的吗?
谢谢你!
I'm developing a windows service in C#.net
, Account: LocalSystem
, System: Windows XP SP3
I want this service to check for all currently logged users if a specific application is running and if not - start this application AS corresponding user name.
I provide domain, name, password, but Start() throws Win32Exception
exception "Access is denied"
process.StartInfo.Domain = domain;
process.StartInfo.UserName = name;
process.StartInfo.Password = password;
process.StartInfo.FileName = fileName;
process.StartInfo.UseShellExecute = false;
process.Start();
The user whose credentials I provide is in administrator group - the application successfully runs if started manually.
Is this accomplished in a different way?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您如何检查正在运行的应用程序?在 Windows Vista 和更高版本中,服务和桌面之间是分离的。这可能意味着您无法访问所需的信息,并且该服务因此而崩溃。服务对话框中有一个“允许与桌面交互”或类似的复选框。您可能想尝试启用它。
How are you checking for applications which are running? In Windows Vista and newer, there is separation between the services and desktops. This may mean that you cannot access the desired information and the service is bombing out for that reason. There is an 'allow interaction with desktop' or similar check box in the service dialog. You might want to try enabling that.