简体   繁体   English

从系统帐户下的服务启动过程

[英]Launching process from service under system account

I am having an issue launching a process from the system account. 我在从系统帐户启动进程时遇到问题。 I just want to make it clear that I am not trying to run it under an interactive session, nor trying to impersonate any account. 我只是想说明一下,我不是要在交互式会话中运行它,也不是要冒充任何帐户。 All I am trying to do is launch a process from the system account into the same session. 我要做的就是从系统帐户启动到同一会话的进程。 The session in which the NTAUTHORITY\\SYSTEM resides is 0 I believe. 我相信NTAUTHORITY \\ SYSTEM所在的会话为0。

I created a simple Windows Service that basically just uses Process.start to launch the executable. 我创建了一个简单的Windows服务,该服务基本上只使用Process.start启动可执行文件。 The Service is a system service. 该服务是一项系统服务。

I installed the service using SC as such: 我使用SC这样安装了服务:

sc create "MYSERVICE" binpath= "C:\Projects\MyService\MyService.exe" displayname= "My Awesome Service"

When I try to manually start the service I get a prompt that says "The ServiceName service on local computers started and then stopped. Some services stop Automatically if they are not in use by other services or programs." 当我尝试手动启动该服务时,出现提示,“本地计算机上的ServiceName服务已启动,然后停止。如果其他服务或程序未使用某些服务,它们会自动停止。”

Along with this the executable is never actually started. 与此相关的是,可执行文件实际上从未启动。 When monitoring it in processhacker I can see that the service does start, but the executable it attempts doesn't. 在processhacker中监视它时,我可以看到该服务确实启动了,但是它尝试执行的可执行文件却没有启动。 Can anyone help me figure out why? 谁能帮我找出原因?

As I stated earlier my service is very basic, all it does is try and launch the executable when started: 如前所述,我的服务非常基础,它所做的就是尝试在启动时启动可执行文件:

  protected override void OnStart(string[] args)
    {
        Process.Start("svrexec.exe");
    }

    protected override void OnStop()
    {
    }

Did you specify full path to your executable? 您是否指定了可执行文件的完整路径? The working folder for the system user is %windir%\\System32. 系统用户的工作文件夹为%windir%\\ System32。

Try Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "svrexec.exe"), or set Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory 尝试使用Path.Combine(AppDomain.CurrentDomain.BaseDirectory,“ svrexec.exe”),或设置Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory

Are you 100% sure it's not running? 您是否100%确定它没有运行? I tried and mine is running under the SYSTEM User Name check Show processes from all users in Task Manager 我试过了,并且我正在系统用户名下运行检查在任务管理器中显示所有用户的进程

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

相关问题 在Windows 7下启动System.Diagnostics.Process时出现问题 - Problem launching a System.Diagnostics.Process under Windows 7 通过服务在用户会话中启动流程 - Launching a process in user’s session from a service Windows服务Process.Start不在网络服务帐户下工作 - Windows service Process.Start not working under network service account 从服务运行msiexec(本地系统帐户) - Running msiexec from a service (Local System account) WCF服务Process.Start在网络服务帐户下模拟为不同的用户 - WCF service Process.Start under network service account impersonating as a different user 如何在本地系统帐户下禁止C#服务启动? - How to forbid C# service from start under LocalSystem account? 使用特定用户名从系统帐户启动流程 - Start process from System Account with a specific User Name 在带有“本地系统帐户”的“ Windows服务”下运行时,.NET Windows 7截屏不起作用 - .NET Windows 7 take screenshot not working when running under 'Windows Service' with 'Local System Account' 在本地系统帐户下的 C# windows 服务中打印 PDF 文件 - printing a PDF file in a C# windows service under Local system account 如何检查可执行文件是作为服务启动还是从SYSTEM帐户启动? - How to check if executable started as service or from SYSTEM account?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM