If you're working with VBScript on Windows 10, one of the most common tasks is prompting users to select a file using a dialog box. While VBScript is an older technology, it's still used in many enterprise environments for automation and administrative scripting. However, Windows 10 doesn't natively support the classic `CommonDialog` control that was available in older versions of Windows. This guide walks you through how to implement a file open dialog box using VBScript on Windows 10, along with practical code examples and troubleshooting tips.
Understanding the Challenge with VBScript and Windows 10
VBScript was designed for Windows Script Host (WSH) and Internet Explorer, but Microsoft has deprecated it in favor of PowerShell. On Windows 10, you can still run VBScript files (.vbs) using the Windows Script Host, but many of the traditional COM components like `MSComDlg.CommonDialog` are either unavailable or require additional setup. This means you need alternative approaches to create a file selection dialog that works reliably on modern Windows 10 systems.
Method 1: Using the Shell.Application COM Object
The most reliable way to create a file open dialog in VBScript on Windows 10 is by leveraging the Shell.Application object. This method uses the BrowseForFolder method for folder selection, or you can use a hybrid approach with an HTML Application (HTA) for a full file dialog. Here's a basic example using Shell.Application for folder selection:

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Select a Folder", 0)
If Not objFolder Is Nothing Then
MsgBox "Selected: " & objFolder.Self.Path
End If
For a true file open dialog, you'll need to use an HTA file or leverage Internet Explorer's legacy components.
Method 2: Using an HTML Application (HTA) for File Selection
An HTA allows you to create a dialog with full file selection capabilities. Save the following as FileSelector.hta:
<html>
<head>
<title>File Selector</title>
<HTA:APPLICATION ID="FileSelector" APPLICATIONNAME="FileSelector" BORDER="thin" BORDERSTYLE="normal" CAPTION="yes" ICON="" MAXIMIZEBUTTON="yes" MINIMIZEBUTTON="yes" SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes" WINDOWSTATE="normal" />
</head>
<body>
<input type="file" id="fileInput" />
<button onclick="selectFile()">Select File</button>
<script language="VBScript">
Sub selectFile()
Dim filePath
filePath = document.getElementById("fileInput").value
If filePath <> "" Then
MsgBox "Selected file: " & filePath
End If
End Sub
</script>
</body>
</html>
This approach gives you a native file dialog without relying on deprecated components.

Method 3: Using PowerShell from VBScript
Another approach is to call PowerShell from within your VBScript to leverage its modern file dialog capabilities. This hybrid method works well on Windows 10:
Set objShell = CreateObject("WScript.Shell")
objShell.Run "powershell -Command ""Add-Type -AssemblyName System.Windows.Forms; $dialog = New-Object System.Windows.Forms.OpenFileDialog; $dialog.ShowDialog() | Out-Null; $dialog.FileName""", 0, True
This executes a PowerShell command that opens a standard Windows file open dialog and returns the selected file path.

Common Issues and Troubleshooting
When working with VBScript file dialogs on Windows 10, you may encounter several issues:
- Permission errors: Ensure your script runs with appropriate permissions, especially in corporate environments with restricted policies.
- Deprecated components: The
MSComDlg.CommonDialogcontrol is not available on Windows 10. Use the methods above instead. - 64-bit vs 32-bit: If you're running 64-bit Windows 10, make sure your VBScript host matches the architecture of the COM objects you're trying to use.
- Internet Explorer dependencies: Since IE is deprecated, avoid relying on IE-specific components for file dialogs.
Best Practices for VBScript File Dialogs on Windows 10
When implementing file dialogs in VBScript on Windows 10, consider these best practices:
- Use HTA files for complex dialog requirements—they offer the most flexibility.
- For simple folder selection,
Shell.Applicationis lightweight and reliable. - Consider migrating critical scripts to PowerShell for better long-term support.
- Always test your scripts on the target Windows 10 version, as behavior can differ between builds.
- Handle cases where the user cancels the dialog to avoid runtime errors.
Complete Working Example
Here's a complete VBScript that combines error handling and user feedback:
On Error Resume Next
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Select a Folder", 0)
If Not objFolder Is Nothing Then
selectedPath = objFolder.Self.Path
MsgBox "You selected: " & selectedPath, vbInformation, "Selection"
Else
MsgBox "No folder was selected.", vbExclamation, "Cancelled"
End If
On Error GoTo 0
This script handles the case where the user clicks "Cancel" and provides appropriate feedback.
Conclusion
While VBScript is a legacy technology, it's still possible to create functional file open dialogs on Windows 10 using the methods described above. The Shell.Application object remains the most straightforward approach for folder selection, while HTAs provide full file dialog capabilities. For new projects, consider transitioning to PowerShell, which offers more robust file dialog support and is actively maintained by Microsoft.





















