预建的SET环境变量不起作用

时间:2017-05-05 17:17:53

标签: powershell environment-variables

我目前正在尝试制作一个使用预构建的Visual Studio的应用程序。

作为我的命令,我有许多人使用相同的命令部分,让我们说:

powershell.exe -ExecutionPolicy unrestricted C:folder1\bin\something.exe "variable1" "variable2"
powershell.exe -ExecutionPolicy unrestricted C:folder1\bin\something.exe "variable1" "variable2"
powershell.exe -ExecutionPolicy unrestricted C:folder1\bin\something.exe "variable1" "variable2"
powershell.exe -ExecutionPolicy unrestricted C:folder1\bin\something.exe "variable2" "variable4"
powershell.exe -ExecutionPolicy unrestricted C:folder1\bin\something.exe "variable3" "variable5"

我想在顶部设置一个变量,它不会改变,所以:powershell.exe -ExecutionPolicy unrestricted C:folder1\bin\something.exe

我目前正在这样做:

SET VAR = powershell.exe -ExecutionPolicy unrestricted C:folder1\bin\something.exe

and trying to call it this way : 

VAR "variable1" "variable2"

VAR "variable1" "variable2"

VAR "variable1" "variable2"

VAR "variable2" "variable4"

VAR "variable3" "variable5"
  

但这不会起作用,为什么要抬头?

2 个答案:

答案 0 :(得分:0)

我发现了问题,SET VAR ="某事"

" ="

之间必须没有空格

答案 1 :(得分:0)

为什么要调用powershell只是为了调用另一个可执行文件?为什么不直接调用可执行文件并跳过Powershell层?

SET VAR="C:folder1\bin\something.exe"

VAR "variable1" "variable2"

VAR "variable1" "variable2"

VAR "variable1" "variable2"

VAR "variable2" "variable4"

VAR "variable3" "variable5"