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.
.dgn
extension, MicroStation opens in its vanilla mode.
How can I start TriForma with a double-click?.mvba
file?A
Perhaps Windows Explorer has forgotten the file association between MicroStation® and the .dgn
extension,
or perhaps you want it to recognise extensions other than .dgn
.
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…
ASSOC
and FTYPE
Q This question also concerns Windows Explorer file associations, but with a desired result that is almost the opposite of the previous questions.
A
Windows Explorer knows of the file association between MicroStation and the .dgn
extension,
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.
USERNAME
? A
You can specify a workspace on the command line in the Windows file association.
The default association, as discussed below, looks something like ustation.exe %L
,
where Windows Explorer substitutes the file path you clicked into %L
.
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 ustation.exe
.
Copy this one-liner to a file named ustation.bat
in the same folder as ustation.exe
…
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
the Windows 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 %%USERNAME%%
,
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" %L
where X
is 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.
.dgn
extension 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 -wu
or -wp
switch in the Editing Action dialog. Of course, the relevant user (.ucf
) or
project (.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 FTYPE
ASSOC/?
and read the informationFTYPE/?
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
the .dgn
extension with TriForma, GeoGraphics, or some other Bentley Engineering Configuration for MicroStation.
ustation.exe
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"
regedit
from 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 .reg
file to
apply the old settingsMicroStation DGN File\shell\open\command
This currently contains the default MicroStation path with no
command-line switches
ustation.exe
If 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 .reg
file; or copy to another computer
and double-click there to propagate your modificationIn 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 %L
(or %1
) argument, thinking that it does just what you want.
Unfortunately for you, Windows knows better: it silently restores the %1
argument.
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.
Windows Explorer settings are stored in the Windows Registry. The procedure is the 'safe' way to edit the Registry, but in this case it's too clever. You have to edit the Registry directly.
Follow the steps described to (5). Don't append any command-line switches.
Instead, you want to remove the %L
(or %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.