This script permits to show you how to open a dialog box by using COM Object : UserAccounts.CommonDialog
Some points:
1. This dialogbox isused in the User Accounts control panel (Nusrmgr.cpl) found in Windows XP.
2. It appears that this os only vaid in Windows XP. It does not work in Server 2008.
3. It's still cool1
Here's a slightly better 1st three lines:
$ObjUsrCom = new-object -ComObject UserAccounts.CommonDialog
$ObjUsrCom.Filter = "PowerShell Scripts|*.ps1|Legacy old scripting rubbish|*.vbs|All Files|*.*"
$ObjUsrCom.FilterIndex = 1
:-)
It is true !!!
It runs only in WinXP and Win2003....
For your code , it is true too, VBS is an old language script, but it was an example ;-)
I will give you a sample with .NET method, but I have a little problem to apply filter option...
See U
Here is a sample that works on all windows versions and opens a dialog to select a folder:
$object = New-Object -comObject Shell.Application
$folder = $object.BrowseForFolder(0, "Select Folder", 0)
if ($folder -ne $null) {
$folder.self.Path
}
pingback from powershell.com/.../627.aspx
Cool script too...
but it is not the same things like my code.
this dialogbox permits to select folder, but not a file.. ;-)
@ Thomas
You can download comdlg at
activex.microsoft.com/.../comdlg32.cab
Unzip and register ocx on W2k8
I think you can run on W2k8 in this case.... ;-)
Anybody can try it ?please
I Don t have w2k8 server...
Ps : if it runs on w2k8 , I will show you other comdlg dialog box