系統(tǒng)運(yùn)維
本來(lái)這篇文章應(yīng)該是上午就寫完的,結(jié)果,不得不承認(rèn)自己有點(diǎn)懶,對(duì)最近手頭上做的項(xiàng)目做了些總結(jié),Powershell開發(fā)運(yùn)維,也做了一段時(shí)間了,今天就來(lái)說(shuō)說(shuō)那些簡(jiǎn)單的GUI的編程運(yùn)維,首先從彈出窗口說(shuō)起吧。
彈出窗口就自己在寫PS GUI代碼是經(jīng)常用到的有3種方式,wscript方式,F(xiàn)orms方式,VB方式,先說(shuō)說(shuō)Wscript方式,這種方式最簡(jiǎn)單,也最簡(jiǎn)陋,只需要兩行代碼就可以簡(jiǎn)單做出彈出窗口。
Wscript方式:
function Read-MessageBoxDialog
{
$PopUpWin = new-object -comobject wscript.shell
$PopUpWin.popup(Hello World)
}
Read-MessageBoxDialog
Forms方式,相對(duì)于Wscript方式來(lái)說(shuō),這種方式寫的代碼比較多但是呈現(xiàn)的樣式比較親切
function Read-MessageBoxDialog
{
param ([string]$Message,
[string]$WindowTitle,
[System.Windows.Forms.MessageBoxButtons]$Buttons = [System.Windows.Forms.MessageBoxButtons]::OK,
[System.Windows.Forms.MessageBoxIcon]$Icon = [System.Windows.Forms.MessageBoxIcon]::None)
Add-Type -AssemblyName System.Windows.Forms
return [System.Windows.Forms.MessageBox]::Show($Message, $WindowTitle, $Buttons, $Icon)
}
Read-MessageBoxDialog -Message Hello World -WindowTitle CustomTitleHere -Buttons OK -Icon Information
最后一種方式就是VB方式,這種方式是在PS中調(diào)用VB的方式來(lái)進(jìn)行彈出窗口,樣式與Forms基本類似
function Read-MessageBoxDialog
{
param ([string]$Message,[string]$WindowTitle)
Add-Type -AssemblyName Microsoft.VisualBasic
return [Microsoft.VisualBasic.Interaction]::MsgBox($Message,\'Information\',$WindowTitle)
}
Read-MessageBoxDialog -Message Hello World -WindowTitle CustomTitleHere
最后可以看出VB的樣式與Forms樣式一樣,但是代碼要比Forms的少很多,如果只是提示窗口,建議用VB形式,如果想讓提示窗口顯示為Information形式,并且OK與Cancel按鈕同時(shí)存在就將Forms方式中的Buttons屬性設(shè)置為 OKCancel
function Read-MessageBoxDialog
{
param ([string]$Message,
[string]$WindowTitle,
[System.Windows.Forms.MessageBoxButtons]$Buttons = [System.Windows.Forms.MessageBoxButtons]::OK,
[System.Windows.Forms.MessageBoxIcon]$Icon = [System.Windows.Forms.MessageBoxIcon]::None)
Add-Type -AssemblyName System.Windows.Forms
return [System.Windows.Forms.MessageBox]::Show($Message, $WindowTitle, $Buttons, $Icon)
}
Read-MessageBoxDialog -Message Hello World -WindowTitle CustomTitleHere -Buttons OKCancel -Icon Information
分享題目:Powershell彈出窗口的幾種方式
瀏覽地址:http://jinyejixie.com/article0/cjosio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司、做網(wǎng)站、定制開發(fā)、品牌網(wǎng)站設(shè)計(jì)、標(biāo)簽優(yōu)化、虛擬主機(jī)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
網(wǎng)頁(yè)設(shè)計(jì)公司知識(shí)