Questions similar to this appear on the Be Communities MicroStation Forum.
Q These questions concern Windows Explorer file associations.
How does Windows associate a given application with a file extension?
For example, MicroStation® is associated with the
.dgn file extension.
We expect that, when we double-click a file in Windows Explorer, the associated application starts automatically.
.dgnextension, MicroStation opens in its vanilla mode. How can I start TriForma with a double-click?
Perhaps Windows Explorer has forgotten the file association between MicroStation® and the
or perhaps you want it to recognise extensions other than
For example, the MicroStation VBA developer can add
.mvba as a recognised file type.
In the case of the TriForma or
GeoGraphics user, you want MicroStation to start with the same command-line switches used with the icon shortcut
installed by the relevant Bentley Engineering Configuration.
You can fix this in at least three ways…
Q This question also concerns Windows Explorer file associations, but with a desired result that is almost the opposite of the previous questions.
Windows Explorer knows of the file association between MicroStation and the
because that association was created when you installed MicroStation.
When you double-click a DGN file, MicroStation starts up and opens that file.
However, in its vanilla mode it won't be using any user or project configuration file.
The CAD administrator wants Windows to start MicroStation when a user double-clicks a DGN file. But, she wants Windows to throw away the file name. Without a file name, MicroStation opens the MicroStation Manager dialog. You can explore this route to find how to stop Windows passing the file name to MicroStation.
Q What about workspaces? By default, the Windows file association set up when MicroStation is installed specifies no workspace, so if I double-click a file name MicroStation start with the default workspace.
You can specify a workspace on the command line in the Windows file association.
The default association, as discussed below, looks something like
where Windows Explorer substitutes the file path you clicked into
You want the command line to include an environment variable, but evaluate it before passing the result to MicroStation.
In other words, something like this:
ustation.exe -wuUserWorkspace %L.
There is a way to substitute a Windows environment variable into the file association. There is a trick: you must …
The batch file apparently does nothing except to wrap
Copy this one-liner to a file named
ustation.bat in the same folder as
rem ustation batch file passes all command-line arguments to MicroStation "C:\Program Files\Bentley\Program\ustation.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9
Suppose that you have a user configuration file named after
USERNAME. You could tell Windows Explorer to use that configuration file like this …
"C:\Program Files\Bentley\Program\ustation.bat" -wu%%USERNAME%% %L
Since the file assocation applies to all users, whoever is logged on will start MicroStation using the settings specified in their personal user configuration file. It's up to the CAD Administrator to ensure that everyone wanting to use MicroStation has a personal UCF.
The reason that this convoluted process works is that the batch file will process
first removing the outer percent signs, then realising that what's left is an environment variable, which it evaluates.
Why the Windows Explorer shortcut can't process the environment variable I don't know:
if you know the reason, or a way to get it to work, let us know!
Windows Explorer appears to have lost capability moving from Windows XP to Windows 7. The methods below work for Windows XP but not for Windows 7 — Windows 7 doesn't have the Folder Options dialog with the subsequent Edit File Type dialog.
"X:\Program Files\Bentley\Program\MicroStation\ustation.exe" %Lwhere
Xis the disk drive where MicroStation is installed, and
%L(that's capital letter L) tells Explorer to substitute the long file name of the file you double click. Wrap a path in quotes if it contains spaces.
.dgnextension using Windows Explorer, several options will pop up. You can assign a default action, so a double-click always starts, say MicroStation, but right-click|select from list gives the option to open using PowerDraft
You can also associate a project or user workspace with a MicroStation file type. Simple append the
workspace file name using the
-wp switch in the Editing Action dialog. Of course, the relevant user (
.pcf) workspace file must exist in MicroStation's
Workspace folder …
ustation.exe -wuUserWorkspace -wpProjectworkspace %L
Windows provides a facility to replicate the steps in Windows Explorer (1) at a command prompt. Unless you really like using the command prompt, then probably methods (1) or (3) are preferable.
ASSOC/?and read the information
FTYPE/?and read the information
The following applies to Windows XP. Registry contents may vary in
other versions of Windows. These instructions suppose that you want to associate
.dgn extension with TriForma, GeoGraphics, or some other Bentley Engineering Configuration for MicroStation.
In this example for GeoGraphics, the full text of the command-line is:
"C:\Program Files\Bentley\Program\MicroStation\ustation.exe" -wumsgeo -wigeograph -wc"C:\Program Files\Bentley\Program\GeoGraphics\config\gglocal.cfg"
regeditfrom the Start|Run menu)
HKEY_CLASSES_ROOT, search for
MicroStation DGN File
MicroStation-default-assoc.reg. If something subsequently goes wrong, just double-click the
.regfile to apply the old settings
MicroStation DGN File\shell\open\commandThis currently contains the default MicroStation path with no command-line switches
ustation.exeIf any path includes spaces, wrap it in double-quotes
MicroStation DGN File, and choose Export from the shortcut menu. Save to something like
MicroStation-TriForma-assoc.reg. If you need to, you can reapply this setting by double-clicking the
.regfile; or copy to another computer and double-click there to propagate your modification
In a large MicroStation shop, with many networked files, a particular file is likely to use a variety of settings set up by its project configuration file. If a user can open a file with a double-click, then the settings won't be defined. MicroStation won't find all its line-styles, cells, reference models, etc., and the DGN model is likely to appear incomplete.
In this case, the CAD administrator wants to stop users opening a file with vanilla MicroStation. Rather, she wants a user to start MicroStation, which then pops the MicroStation Manager dialog.
The real solution is in the file association stored in the Windows Registry. A phantom solution lies in Windows Explorer, and first we'll explore that method, because it's the most obvious, to see why we need to modify the Registry.
We want to stop passing the file name to MicroStation when we double-click a DGN file.
You can use the procedure to edit the file association the 'official' way.
You can delete the
%1) argument, thinking that it does just what you want.
Unfortunately for you, Windows knows better: it silently restores the
The result is that you think you fixed the problem, but when you go to test it, MicroStation continues
to open the DGN file you double-clicked.
Follow the steps described to (5). Don't append any command-line switches.
Instead, you want to remove the
%1) placeholder at the end of the line.
The result should be simply the command to start MicroStation (
ustation.exe) with no arguments.
Save your changes to the Registry.
Now start Windows Explorer and double-click a DGN file. Explorer tells MicroStation to start but, with no file name present, MicroStation pops the MicroStation Manager dialog. Just what you want!
But remember, if you use Windows Explorer to edit this association, it's going to put that
%1 argument back in.