相关疑难解决方法(0)

如何在中间编写带参数的PowerShell别名?

我正在尝试设置Windows PowerShell别名以使用某些参数运行MinGW的g ++可执行文件.但是,这些参数需要在文件名和其他参数之后.我不想经历尝试设置功能和所有这些的麻烦.有没有办法简单地说:

alias mybuild="g++ {args} -lib1 -lib2 ..."
Run Code Online (Sandbox Code Playgroud)

或类似的规定?我对PowerShell并不熟悉,而且我很难找到解决方案.任何人?

powershell alias g++

67
推荐指数
3
解决办法
2万
查看次数

删除脚本中的别名

我可以删除这样的别名:

Remove-Item Alias:wget
Run Code Online (Sandbox Code Playgroud)

然后尝试别名给出预期的结果:

PS > wget
wget : The term 'wget' is not recognized as the name of a cmdlet, function,
script file, or operable program.
Run Code Online (Sandbox Code Playgroud)

但是,如果我将相同的内容添加到脚本中,

PS > cat wget.ps1
Remove-Item Alias:wget
wget
Run Code Online (Sandbox Code Playgroud)

它给人意想不到的结果

cmdlet Invoke-WebRequest at command pipeline position 1
Supply values for the following parameters:
Uri:
Run Code Online (Sandbox Code Playgroud)

powershell

15
推荐指数
2
解决办法
6549
查看次数

标签 统计

powershell ×2

alias ×1

g++ ×1