在PowerShell中运行CMD命令 [英] Running CMD command in PowerShell

查看:239
本文介绍了在PowerShell中运行CMD命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法正常运行PowerShell命令。它所要做的就是运行将在CMD提示窗口中运行的命令。

I am having a bunch of issues with getting a PowerShell command to run. All it is doing is running a command that would be run in a CMD prompt window.

这是命令:

C:\程序文件(x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe PCNAME

我尝试了以下尝试,但均未成功(我尝试了多次迭代以尝试使之可行。语法可能全部搞砸了):

I have tried the following with no success (I have tried many iterations of this to try and get one that works. Syntax is probably all screwed up):

$TEXT = $textbox.Text #$textbox is where the user enters the PC name.
$CMDCOMMAND = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe"
Start-Process '"$CMDCOMMAND" $TEXT'
#iex -Command ('"C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe"' $TEXT)

该命令将打开SCCM远程连接窗口,该窗口连接到用户在文本框中指定的计算机。

The command will just open SCCM remote connection window to the computer the user specifies in the text box.

推荐答案

尝试一下:

& "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe" PCNAME

对于PowerShell,字符串 ...只是一个字符串,PowerShell通过将其回显到屏幕来对其进行评估。若要使PowerShell执行名称为字符串的命令,请使用调用运算符&

To PowerShell a string "..." is just a string and PowerShell evaluates it by echoing it to the screen. To get PowerShell to execute the command whose name is in a string, you use the call operator &.

这篇关于在PowerShell中运行CMD命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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