回答
你指的是像氣球提示。 VBScript本身並沒有這樣的功能。您需要使用第三方組件。
另外,PowerShell IS能夠做到這一點。
[reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[reflection.assembly]::loadwithpartialname("System.Drawing")
$notify = new-object system.windows.forms.notifyicon
$notify.icon = [System.Drawing.SystemIcons]::Information
$notify.visible = $true
$notify.showballoontip(10,"Reboot Required","Please restart your computer",[system.windows.forms.tooltipicon]::None)
使用VS2010之外,我會如何編譯這個?使用csc? – LamonteCristo 2012-04-25 13:02:51
@ makerofthings7:powershell是一種解釋型語言,包含在Windows 7/2008R2中,可下載XP/Vista/2003/2008。從http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx開始 – 2012-04-26 02:44:58
如果你可以去純粹的PowerShell,我強烈推薦這個片段很好!
例
代碼
##################
# Messenger like popup dialog
# Usage:
# New-Popup.ps1
# New-Popup.ps1 -slide -message "hello world" -title "PowerShell Popup"
param(
[int]$formWidth=200,
[int]$formHeight=110,
[string]$title="Your title here",
[string]$message="Your message here",
[int]$wait=4,
[switch]$slide
)
[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
################
# extract powershell icon if doesn't exist
$icon = "$env:temp\posh.ico"
if(!(test-path -pathType leaf $icon)){
[System.Drawing.Icon]::ExtractAssociatedIcon((get-process -id $pid).path).ToBitmap().Save($icon)
}
################
# Create the form
$form = new-object System.Windows.Forms.Form
$form.ClientSize = new-object System.Drawing.Size($formWidth,$formHeight)
$form.BackColor = [System.Drawing.Color]::LightBlue
$form.ControlBox = $false
$form.ShowInTaskbar = $false
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedSingle
$form.topMost=$true
# initial form position
$screen = [System.Windows.Forms.Screen]::PrimaryScreen
$form.StartPosition = [System.Windows.Forms.FormStartPosition]::Manual
if($slide){
$top = $screen.WorkingArea.height + $form.height
$left = $screen.WorkingArea.width - $form.width
$form.Location = new-object System.Drawing.Point($left,$top)
} else {
$top = $screen.WorkingArea.height - $form.height
$left = $screen.WorkingArea.width - $form.width
$form.Location = new-object System.Drawing.Point($left,$top)
}
################
# pictureBox for icon
$pictureBox = new-object System.Windows.Forms.PictureBox
$pictureBox.Location = new-object System.Drawing.Point(2,2)
$pictureBox.Size = new-object System.Drawing.Size(20,20)
$pictureBox.TabStop = $false
$pictureBox.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::StretchImage
$pictureBox.Load($icon)
################
# create textbox to display the message
$textbox = new-object System.Windows.Forms.TextBox
$textbox.Text = $message
$textbox.BackColor = $form.BackColor
$textbox.Location = new-object System.Drawing.Point(4,26)
$textbox.Multiline = $true
$textbox.TabStop = $false
$textbox.BorderStyle = [System.Windows.Forms.BorderStyle]::None
$textbox.Size = new-object System.Drawing.Size(192,77)
$textbox.Cursor = [System.Windows.Forms.Cursors]::Default
$textbox.HideSelection = $false
################
# Create 'Close' button, when clicked hide and dispose the form
$button = new-object system.windows.forms.button
$button.Font = new-object System.Drawing.Font("Webdings",5)
$button.Location = new-object System.Drawing.Point(182,3)
$button.Size = new-object System.Drawing.Size(16,16)
$button.Text = [char]114
$button.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat
$button.Add_Click({ $form.hide(); $form.dispose() })
if($slide) {$button.visible=$false}
################
# Create a label, for title text
$label = new-object System.Windows.Forms.Label
$label.Font = new-object System.Drawing.Font("Microsoft Sans Serif",8,[System.Drawing.FontStyle]::Bold)
$label.TextAlign = [System.Drawing.ContentAlignment]::MiddleLeft
$label.Text = $title
$label.Location = new-object System.Drawing.Point(24,3)
$label.Size = new-object System.Drawing.Size(174, 20)
################
# Create a timer to slide the form
$timer = new-object System.Windows.Forms.Timer
$timer.Enabled=$false
$timer.Interval=10
$timer.tag="up"
$timer.add_tick({
if(!$slide){return}
if($timer.tag -eq "up"){
$timer.enabled=$true
$form.top-=2
if($form.top -le ($screen.WorkingArea.height - $form.height)){
#$timer.enabled=$false
$timer.tag="down"
start-sleep $wait
}
} else {
$form.top+=2
if($form.top -eq ($screen.WorkingArea.height + $form.height)){
$timer.enabled=$false
$form.dispose()
}
}
})
# add form event handlers
$form.add_shown({
$form.Activate()
(new-Object System.Media.SoundPlayer "$env:windir\Media\notify.wav").play()
$timer.enabled=$true
})
# draw seperator line
$form.add_paint({
$gfx = $form.CreateGraphics()
$pen = new-object System.Drawing.Pen([System.Drawing.Color]::Black)
$gfx.drawLine($pen,0,24,$form.width,24)
$pen.dispose()
$gfx.dispose()
})
################
# add controls to the form
# hide close button if form is not sliding
if($slide){
$form.Controls.AddRange(@($label,$textbox,$pictureBox))
} else {
$form.Controls.AddRange(@($button,$label,$textbox,$pictureBox))
}
################
# show the form
[void]$form.showdialog()
另存爲新-Popup.ps1保持使用相同。 Kudo的作者http://scriptolog.blogspot.com/2008/02/windows-messenger-like-popup.html
看起來很酷。我將不得不弄清楚如何取消聲音並使其淡入淡出(不需要點擊) – LamonteCristo 2012-04-26 18:48:00
最好的是,您可以將此ps1複製到HD上的某個位置,並隨時通過psexec發送消息和您的計算機名稱的列表 – dc5553 2012-04-26 18:50:43
應該有一種方法可以使用原生WinRM/Powershell工具來執行與代理命令行程序的遠程處理。你知道如何做到這一點? (Exchange 2010做這個例子) – LamonteCristo 2012-04-26 19:03:29
- 1. MSGBOX VBscript的
- 2. VBScript的正則表達式負面Lookbehind替代方案
- 3. playN替代方案
- 4. Example.com替代方案
- 5. TFS替代方案
- 6. WSO2替代方案
- 7. Nginx:more_clear_headers替代方案
- 8. AppDomain.AppendPrivatePath替代方案?
- 9. Javascript。替代方案
- 10. android.net.wifi.WIFI_HOTSPOT_CLIENTS_CHANGED替代方案
- 11. MediaMetadataRetriever替代方案?
- 12. HTMLElementVariable.animate(...)替代方案?
- 13. 替代方案deleteOnExit
- 14. VSTO替代方案
- 15. 任何替代jquery msgbox
- 16. _path的替代方案
- 17. $ httpProvider.responseInterceptors的替代方案
- 18. SELECT DISTINCT的替代方案
- 19. RPM的fakeroot替代方案
- 20. Treeview的替代方案
- 21. QUnit的替代方案
- 22. gethostbyname的替代方案
- 23. Java.sql.time的替代方案
- 24. Git的StatSVN替代方案?
- 25. ValidateRequest =「false」的替代方案
- 26. Cookie的替代方案
- 27. Android - OpenCV的替代方案?
- 28. JCA的替代方案
- 29. jpeg_read_header的替代方案libjpeg
- 30. iOS3的UILocalNotification替代方案
你可以從VBScript調用PowerShell。這實際上可能是最簡單的解決方法。在我看來,VBScript確實不適合在需要任何用戶界面的情況下使用(除非您使用它來用ASP編程網頁,但即使這樣也不利於主機端GUI)。 – HK1 2012-04-25 12:35:49