Running VBS script from Microstation Shortcut - possible?

Hi, I thought this was the best place to post this query. I have a script which I want to run each time our users start MS. I currently have a shortcut that uses the WC command switch and in theory I should only have to run this script once however to ensure the users receive the appropriate settings, I'd like my VBS script to run first before MS completes processing the cfg files during startup. The reason for this is the script sets a User Environment variable which one of my cfg files then uses to set different group settings depending on the value of the variable.

Does anyone know if it is possible to achieve this?

Thanks

  • You could easily do this and a lot more from a hta file, check out:

    communities.bentley.com/.../121758.aspx



  • Hi Bear

    I've considered that (and it is a possibility) but I wanted to know if the more common method of a standard shortcut would work before I took the vbs into an HTA instead and then issued a shortcut to the HTA to users

  • Windows Actions before Application Starts

    What you are asking is in the domain of Windows rather than an application (any application, not just MicroStation). Windows Explorer knows how to do certain things when you double-click or right-click (or perform the menu equivalents) on a file of a known type.

    Known types of file are those that are registered by an installer when you install an application on a computer. Microsoft Word registers the .doc extension; Adobe registers the .pdf extension; Bentley registers the .dgn extension. When you double-click a DOC file, Windows Explorer knows it should start Microsoft Word. When you double-click a PDF file, Windows Explorer knows it should start Adobe Acrobat. When you double-click a DGN file, Windows Explorer knows it should start Bentley MicroStation.

    You are asking Windows Explorer to do something different: when you activate a XXX file, run a VB Script. Of course, Windows Explorer already knows what to do with a VBS script file: run it in the Windows Scripting Host interpreter.

    So what you're asking Windows Explorer to do is this …

    1. When you open a XXX file, run a VB Script
    2. Pass the name of the XXX file to VB Script
    3. Let the VB Script do whatever it wants to do with the XXX file

    From the above, you can see that what you want has nothing to do with MicroStation (or any other application) and lots to do with Windows and Windows Explorer. So the right place to search for an answer will be a Windows Forum that deals with those topics.

    By the way, don't forget to tell your IT department that you plan on running a VB Script when opening a file. Let us know their response.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Hi Jon, thanks for responding. I always appreciate your comments

    My script doesn't do what you outlined in the bullet points. Our users always start MS from a single shortcut with a -WC command switch so the vbs script doesn't affect DGN file extensions in any way, it merely creates a variable that the config pointed to on the shortcut uses. I could quite simply have the script run when the user logs in via the startup folder. I've been in discussion with our IT dept and they've read the script and have no issues with it. As CAD manager the script allows me to control the settings for each user via an excel document (which the script does a string comparison search against the value of %username%) There are more sophisticated methods to control this via Active directory or GPO however that is not in my domain (so to speak) but our IT dept is happy to allow our dept to manage this aspect of administration given its low scope.

  • Just to update my progress on this, I found that trying to load the VBscript as a parameter during MS startup is not possible so instead I simply concentrate on loading the VBscript but it has an added sub which starts MS with the required -wc switch after the script actions are complete. The script is then compiled into a true .EXE and a shortcut to this is issued to all users. It works flawlessly and much easier to administer users without A) needing to get our IT company involved for creating Active Directory security groups and B) saves me having to create multiple shortcuts with different -WC switches for different groups of users and ensuring that each user has the correct one at all times.

  • MicroStation configuration files can look at the value of %username% and act accordingly.


    Charles (Chuck) Rheault
    CADD Manager

    MDOT State Highway Administration
    Maryland DOT - State Highway Administration User Communities Page

    • MicroStation user since IGDS, InRoads user since TDP.
    • AutoCAD, Land Desktop and Civil 3D, off and on since 1996
  • Yeah I know they can and I do use that in my configs, however using an external CSV as user index, I can edit the file easier in excel en-masse and my custom exe searches this and sets environment variables from the results of the search. Also, I have found that for some unknown reason, Microstation does not always process environment variables which is a odd yet I have no idea why.

  • You can always have an %include in your MSLocal.cfg which points to a central CFG which has an %if...elseif option.

    Place a 'flag' text file in a discipline specific root folder... then use the %if-elseif to detect the existence then act on it but setting a further set of root variables, then return to the MSLocal to go on to the rest of config...

    Alternately, if you are an admin, you can do a bit of ground work to silo users into business groups under the member group security settings of the network, then have a logon script detect the business group setting and pass it onto the local machine environment, which then can be used by MS config,,.

    CADMinistrator ®

  • ' Also, I have found that for some unknown reason, Microstation does not always process environment variables which is a odd yet I have no idea why.'

    Never had this as an issue. I use environment variables and session variables set from a hta files and never had a variables missed or dropped.



  • 'I have found that for some unknown reason, Microstation does not always process environment variables which is a odd yet I have no idea why'

    What does your debug=4... debug.txt have in it...

    CADMinistrator ®