Winscripter
  WSH
  Forums
  Downloads
  Books
  Links
  Amazon




Login
Register

© winscripter.com
1998-2004







Using Microsoft's Common Dialog Control

Posted by on Saturday, January 17, 2004 (PST)

The Common Dialog Control is used by most windows applications to show the familiar OpenFile, SaveFile, etc... dialog boxes.

Everyone is familar is the Common Dialog - File Open/Save control in Windows, you use it everyday. This script shows you how to script the Common Dialog control and put it to work for you.

Note: This script will run on system's with the Microsoft Controls properly installed. If your machine has virtually any of Microsoft's development tools installed, you probably have these controls. I have yet to find an easy way to distribute these, I am open to suggestions.

 

// Create the Object
cd = new ActiveXObject("MSComDlg.CommonDialog");
// Set file filter
cd.Filter = "All Files(*.*)|*.*|JScript Files(*.js)|*.js";
cd.FilterIndex = 2;
// Must set MaxFileSize. Otherwise you will get an error
cd.MaxFileSize = 128;
// Show it to user
cd.ShowOpen();
// Retrieve file + path
file = cd.FileName;
// If the user does enter file exit
if ( !file ) {
   WScript.Echo("You must enter a file name");
   WScript.Quit(0);
} else {
   WScript.Echo("The user selected:\n" + file );
}

 
 


 


Comments:

Porting the Common Control Box
By robvh on Wednesday, March 17, 2004 (PST)

Your problem is not only installing the OCX, but to 'license' it for scripting.

And I don't think MS would like it if you copy your license key from

HKEY_CLASSES_ROOT\Licenses\4D553650-6ABE-11cf-8ADB-00AA00C00905 to any client

Reply to this Comment

License for Common Dialog Control
By thongpham on Monday, March 29, 2004 (PST)
Beside copying your "license string" to the clients' machine, do you know of any method that would allow you to grant the license to your client (eg, a public license) without violating copyrighted material? Please let me know. Thank you.

Reply to this Comment

AUTOMATION/COM
By ED34 on Wednesday, August 11, 2004 (PST)
IS THERE A SCRIPT TO ROOT THROUGH MY HARD DRIVE AND PARSE OUT EVERY PROGRAM ID  (FOR EVERY APPLICATION I HAVE INSTALLED) ?

IT WOULD SURE BE NICE.

THANKS,    ED

Reply to this Comment

OLEView
By Daren on Tuesday, August 31, 2004 (PST)

ED34,

Script to dump ProgIDs... I might have to work on that one.

You might want to try using OLEView, it is an application that displays all the COM objects installed on your machine and their associated ProgIDs. I should mention that this is normally a developer tool and can be a bit cryptic but tells you everything.

Daren

Reply to this Comment

Add Your Comment



WSH and ADSI Administrative Scripting

New Articles
  • List installed COM objects and associated ProgIDs
    Script: Lists all COM Objects and their associated ProgIDs (If available). Win32_ClassicCOMClassSetting

  • Script: File Rotator
    Script: Rotate files where the most current file has the lowest number in the archive. When files exceed the retention period, they are deleted. Typically used for log files, backups, etc..

  • Script: Create IIS Website and DNS record
    Script: Dan Casier sent me this script that will create a website and appropriate DNS record. The script is intended for Windows 2000 Server with local DNS and necessary DNS mof installed.


  • Winscripter   |  WSH   |  Forums   |  Downloads   |  Books   |  Links   |  Amazon