简体   繁体   English

使用特定用户名从系统帐户启动流程

[英]Start process from System Account with a specific User Name

I'm developing a windows service in C#.net , Account: LocalSystem , System: Windows XP SP3 我正在使用C#.netAccount: LocalSystemSystem: Windows XP SP3开发Windows服务
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" 我提供域名,密码,但Start()抛出Win32Exception异常“访问被拒绝”

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! 谢谢!

How are you checking for applications which are running? 你是如何检查正在运行的应用程序的? In Windows Vista and newer, there is separation between the services and desktops. 在Windows Vista及更高版本中,服务和桌面之间存在分离。 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. 您可能想尝试启用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM