Trials & Tribulations of running windows scripts in Vista

I have a client with a legacy VB6 app which we occasionally tweak. It has an exe and many DLL’s. Over the years I graduated from using a batch file to a script (WSF) file to let them pull updates. The script file checks the date of the local version of the file against the date of the files on the server. If any are newer, then the script copies the file down and unregisters then re-registers the DLL.

It’s been a great solution for many many years. Until they started getting new machines with Vista on them.

I had one permission issue after another. This was not simply a matter of running the script as admin. Even (testing) with UAC off, I had no better luck.

To begin with the users run the script that lives on the server. Vista doesn’t like this.

I had to move the script to the local machine.

The script references drive letters that are mapped to network drives.

Changed all network pointers within the script to IP addresses. I haven’t tried using fully qualified network names. That’s a good next step in case IPs change down the road.

Script must be run as admin in order for DLL registration to be allowed. But alas, there is no built in “Run as Administrator” context menu.

Luckily, somebody built one. It’s part of a great updated Vista PowerToys collection. Start with the TechNet Magazine article, New Elevation PowerToys for Windows Vista by Michael Murgolo.

When the original script registered and unregistered DLLs, it did so quietly. In Vista the response messages were displayed.

I modified the script to make those be silent using the command line switch: regsvr32 /s

Now this is a nice short little list. But just imagine how many hours of frustration I went through to get to this.

One thing I found when web searching how to solve this problem was many many blog posts and forum threads from real live sysadmins also complaining vocally about this problem. It seemed as though there would just be no solution at all. The last lingering thing that I don’t like is that the users must right click the shortcut to run the script as an admin. It’s not intuitive. Fortunately we can assure that each user going to Vista can have this explained to them since we’re not talking about thousands of end users. In scenarios where there are lots of end users, I would hope that there are smarter deployment techniques in place. Our .NET apps are all distributed and updated via ClickOnce. Not that this was effortless to achieve. It took years for Microsoft to get the technology almost right and even then we struggled and sometimes still feels like a house of cards.

Don’t breathe!

#1 RichardHowells on 9.23.2009 at 3:39 PM

Click-once is supposed to be able to install com dll's. I've never actually needed to try it, but I have wondered if it could install your kind of legacy app. Maybe a cheat - a small .Net shim that just launches the VB6 app - but also causes the com stuff to d/l and install. Dunno really - just ranting!

#2 Daniel Pratt on 9.23.2009 at 7:01 PM

I believe the mapped drive issue is caused by the fact that mapped drives are per-session. When you "Run as Admin", the process actually runs in a different session. One way to fix this is to establish the mapped drives under the "Run As Admin" session also. This can be done by running cmd.exe "as Admin" and issuing "net use x: \\server\share" commands. I believe the mapped drives will persist, so this should only need to be done once per machine.

Is the mapped drive issue what prevents running scripts from the server or is there another issue with that?

#3 Julie on 9.23.2009 at 7:49 PM

Nice to have friends with this kind of knowledge. :) The mapped drive was an issue with some of the tasks in the script, not about running the script itself.