Open DialogBox by using .NET


posted by Sylvain LESIRE
12-23-2008

Downloads: 467
File size: 443 B
Views: 2,169

Embed
Open DialogBox by using .NET
  1. [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms"
  2.     $objForm = New-Object System.Windows.Forms.OpenFileDialog 
  3.     $objForm.InitialDirectory = "c:\" 
  4.     $objForm.Filter = "PowerShell *.ps1|*.ps1|All Files | *.*" 
  5.     $objForm.Title = "Open DialogBox By .NET" 
  6.     $objForm.FilterIndex =
  7.     $Show = $objForm.ShowDialog() 
  8.      
  9.     If ($Show -eq "Cancel"){ 
  10.         "Canceled by user"                 
  11.     }     Else    
  12.         write-host $objForm.FileName 
  13.     

Next script to open file by using .NET

 

 

@Thomas Lee: Can you try it on W2k8? Can you tell us if it runs....

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.