[英]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.