Windows call .Net CLR in PowerShell script
博客首页 » Windows call .Net CLR in PowerShell script
发布于 12 Apr 2014 23:30
标签 blog
随着XP的退出,主流的OS都开始升级到Windows 7。这使得PowerShell成为一种默认装备。我们可以通过调用.Net CLR库,达到一些原来的shell script难以企及的功能。
Bart在他的这个文章里讨论了调用.Net CLR的方法
http://bartdesmet.net/blogs/bart/archive/2006/09/16/4429.aspx
这是显示系统对话框的代码
PS C:\Users\Foo> [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
PS C:\Users\Foo> [System.Windows.Forms.MessageBox]::Show("Hello")
这是管道与对话框选择结合的代码
PS C:\Users\Foo> gps [a-c]* | where {
>> $s = "Select " + $_.ProcessName + "?";
>> $d = [Windows.Forms.MessageBox]::Show($s, "PowerShell rocks", [Windows.Forms.
MessageBoxButtons]::YesNo, [Windows.Forms.MessageBoxIcon]::Question)
>> $d -eq [Windows.Forms.DialogResult]::Yes
>> }
本页面的文字允许在知识共享 署名-相同方式共享 3.0协议和GNU自由文档许可证下修改和再使用,仅有一个特殊要求,请用链接方式注明文章引用出处及作者。请协助维护作者合法权益。
系列文章
文章列表
- Windows call .Net CLR in PowerShell script
这篇文章对你有帮助吗,投个票吧?
留下你的评论