Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何用Powershell替换Visual Studio命令提示符?_Powershell - Fatal编程技术网

如何用Powershell替换Visual Studio命令提示符?

如何用Powershell替换Visual Studio命令提示符?,powershell,Powershell,我正在尝试以下命令的各种变体: powershell -command "'C:\Program Files (x86)\Microsoft Visual Studio 10.0\vc\vcvarsall.bat' x86" -noexit 我希望用VS环境变量运行Powershell,但没有用。我只是无法正确引用。请查看Bruce Payette的“Windows PowerShell运行中,第二版”中的get BatchFile 也可以通过以下方式使用PowerShell中的这些批处理文

我正在尝试以下命令的各种变体:

powershell -command "'C:\Program Files (x86)\Microsoft Visual Studio 10.0\vc\vcvarsall.bat' x86" -noexit

我希望用VS环境变量运行Powershell,但没有用。我只是无法正确引用。

请查看Bruce Payette的“Windows PowerShell运行中,第二版”中的get BatchFile

也可以通过以下方式使用PowerShell中的这些批处理文件: 执行它们,转储对 然后将这些更改导入到PowerShell中 环境

看一看这张照片。它附带一个命令来调用批处理文件,“记住”它设置了什么环境变量,并将这些变量带到您的PowerShell会话中。事实上,我的个人资料仅用于VS变量,例如:

Import-Module Pscx

function Import-VS9Vars
{
    $vcargs = ?: {$Pscx:Is64BitProcess} {'amd64'} {'x86'}
    Push-EnvironmentBlock -Description "Before importing VS 2008 $vcargs var"
    Invoke-BatchFile "${env:VS90COMNTOOLS}..\..\VC\vcvarsall.bat" $vcargs
}

function Import-VS10Vars
{
    $vcargs = ?: {$Pscx:Is64BitProcess} {'amd64'} {'x86'}
    Push-EnvironmentBlock -Description "Before importing VS 2010 $vcargs vars"
    Invoke-BatchFile "${env:VS100COMNTOOLS}..\..\VC\vcvarsall.bat" $vcargs
}

Import-VS10Vars
重要的命令是Invoke BatchFile。此函数的源代码在下载中提供,因此如果您不想使用整个模块,您可以根据需要复制该函数。

这里有一个示例


别忘了:)

这个链接指的是互联网上的图书摘要。你建议我买这本书是为了了解这本书的内容吗?假设我找到了Get_BatchFile并将其添加到我的个人资料中。如何在命令行上运行powershell并将脚本传递给它?很抱歉,该链接会将我带到提供脚本的PDF并解释其工作原理。它运行vcvarsall.bat并在PowerShell中正确设置变量。我在链接引用的PDF附录A.1.7中找到了您的意思。谢谢