如何从JobObject分离的处理 [英] How to detach a process from a JobObject

查看:161
本文介绍了如何从JobObject分离的处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法分离的过程,从JobObject?
我的问题是,如果我创建一个新的进程与运行方式,像cmd.exe的,那么它将被自动分配给JobObject。如果我想运行我的应用程序从这个CMD也将被分配到这个jobobject。这个问题从这里开始的,因为我的应用程序将创建一个新jobobject并创建一个新的进程,然后将其分配给我的新JobObject,但它不能关联,因为第一CMD开始与运行方式,已经被分配给一个jobobject,并因此,新的工艺是我创建也被分配给这个jobobject。

Is there a way to detach a process, from a JobObject? My problem is, that if i create a new process with RunAs, like cmd.exe, then it will be assigned to a JobObject automatically. And if I want to run my application from this cmd it will also be assigned to this jobobject. The problem starts here, because my application would create a new jobobject and create a new process and then assign it to my new JobObject, but it can't associate, because the first cmd started with runas, is already assigned to a jobobject, and so the new process what I created is also assigned to this jobobject.

所以我的问题是,我怎么能脱离从中将被自动创建,不然我还能怎么解决这个问题jobobject第一CMD?

So my question is, how can I detach the first cmd from the jobobject which will be automatically created, or how else can I solve this problem?

推荐答案

而不是使用运行方式,考虑运行父应用程序作为标准用户,并使用的 CreateProcessWithLogonW 提升。

Instead of using runas, consider running the parent application as the standard user and using CreateProcessWithLogonW to elevate.

另外,您也可以使用 PSEXEC 当中,虽然设计用于远程执行命令,往往可以逃避在本地计算机上当前的上下文中。可以要么使用PSEXEC作为替代的runas:

Alternatively, you could use psexec which, although designed for executing commands remotely, can often be useful to escape your current context on the local computer. You could either use psexec as an alternative to runas:

psexec -i \\%COMPUTERNAME% -u adminuser cmd.exe

(会提示你输入密码),或者你可以使用runas方式,然后

(you will be prompted for the password) or you could use runas and then

psexec -s -i \\%COMPUTERNAME% parent.exe

在本地系统上下文中运行 parent.exe 。这将难逃现有的作业对象,因为新进程是从系统服务启动。

to run parent.exe in local system context. This will escape the existing job object, because the new process is launched from a system service.

请注意,使用 PSEXEC -i 标记是在Vista中棘手后来因为它使用多个终端服务器会议更广泛;在那种情况下你可能会更好过与运行方式坚持。幸运的是,你的问题只适用于XP。 : - )

Note that using psexec with the -i flag is trickier in Vista and later because it uses multiple terminal server sessions more extensively; in that scenario you're probably better off sticking with runas. Luckily your problem only applies to XP. :-)

这篇关于如何从JobObject分离的处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆