在Windows中的另一个用户下运行进程
问题描述:
我想在特定用户帐户下的Windows中启动一个进程。 使用ProcessStartInfo
的启动过程可以在本地和当您进行活动的交互式会话时使用。它不适用于活动会话不存在的远程场景。在Windows中的另一个用户下运行进程
在远程计算机上,Service ABC
正在管理员帐户(domain\adminuser)
下运行,该帐户在相同的管理员帐户下启动powershell.exe
以启动脚本并驱动流。
在脚本中,我试图启动进程[非交互式],但未能启动相同的进程。
$Processinfo = New-Object System.Diagnostics.ProcessStartInfo
$Processinfo.UseShellExecute = $false
$Processinfo.LoadUserProfile = $false
$Processinfo.CreateNoWindow = $true
$Processinfo.Username = "domain\user"
$Processinfo.PasswordInClearText = "testpass"
$Processinfo.FileName = "abc.exe"
我不明白为什么我不能从会话0
答
推出非交互式过程在本地运行一个原因,你可以简单地使用Start-Process
$Credentials = Get-Credentials
Start-Process -Credential $Credentials -FilePath 'C:\Windows\notepad.exe'
对于Remote机器可以使用WMI Create
使用-List
参数:
(Get-WmiObject win32_process -ComputerName $computer -Credential $Credentials -List).Create("notepad")
怎么ar你是否在远程调用? –
@RanadipDutta,使用始终在机器中运行的服务。我确实提供了使用'Remote-PSSession'执行的脚本 – Reddy
请将其发布。所以我们也可以看看这个。 –