【问题标题】:Start explorer.exe remotely with a path specified in Powershell使用 Powershell 中指定的路径远程启动 explorer.exe
【发布时间】:2017-02-09 16:08:42
【问题描述】:

我的问题是我可以在远程机器上调用命令 explorer.exe 而不给它任何路径参数,但是当我输入时:

Invoke-Command -ComputerName PC01 -Credential $cred -ScriptBlock  {explorer.exe "C:\Foldername"} 

什么都没有发生,除了我在日志中收到一条错误条目:

服务器 {75DFF2B7-6936-4C06-A8BB-676A7B00B24B} 未在要求的超时时间内向 DCOM 注册。

【问题讨论】:

  • 你为什么要这样做?
  • 您最终要以什么身份运行此过程? ...

标签: powershell powershell-remoting dcom


【解决方案1】:

首先,如果您直接在本地系统上尝试此操作,GUI 将正确弹出。

Invoke-Command  -ScriptBlock  {C:\Windows\explorer.exe "C:\folder"}

但问题在于,powershell 如何打开从远程系统调用的 GUI 控制台。基本上,它没有要举行的会话。 您需要一个桌面会话来做到这一点

在这种情况下,您应该使用 PSEXEC-i

psexec -i -d -s c:\windows\explorer.exe C:\folder

从这里下载它:PSExec-v2.11。此链接包含所有说明以及如何使用每个实用程序的示例。

希望对你有帮助。

【讨论】:

  • 嗨,谁(哪个用户帐户)会在目标计算机上看到这个?
  • 在目标系统中,必须有人登录。桌面会话应该存在。
  • @RanadipDutta;谢谢你的回答。但是,我遇到的问题是,只有手动输入命令时,才能以这种方式执行命令。如果我尝试将其放入已保存的脚本中 - 它会尝试在本地执行所有内容。我的代码的目的是超越所有密码提示,在远程 PC 上创建一个文件夹并以交互方式打开它。
  • @RanadipDutta;当手动输入控制台时,这工作得很好:$username = "PC01\User"; $password = "Password01"; $secstr = New-Object -TypeName System.Security.SecureString; $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}; $cred = new-object -typename; System.Management.Automation.PSCredential -argumentlist $username, $secstr; Enter-PSSession -ComputerName PC01 -Credential $cred; $path = "PC01\C:\testfolder"; New-Item -Path $path -ItemType directory; psexec.exe -i -s C:\windows\explorer.exe "C:\testfolder"; Exit-PSSession;
猜你喜欢
  • 1970-01-01
  • 2013-12-07
  • 1970-01-01
  • 2011-07-24
  • 2015-10-28
  • 2016-06-28
  • 2014-10-02
  • 2017-09-18
  • 1970-01-01
相关资源
最近更新 更多