Craig Box's journeys, stories and notes...


Posts Tagged ‘windows’

Access 2003 fires up Windows Installer every time you run it

Monday, April 30th, 2007

Found an interesting problem this morning - Access 2003 fires up Windows Installer (msiexec.exe) every time you start it, and for users without administrator rights, it just doesn't go.

After looking at dozens of newsgroup posts and trying a few solutions, I finally had enough debugging information to find the solution that worked: registry keys are missing from HKLM\Software\Microsoft\Jet\4.0\Engines. Copy them from another machine (changing paths where required) and it works again!  Would of course love to know what caused a bunch of registry keys to just disappear...

For those interested, I found that msiexec was writing to a log file using Filemon, and the log file contained the error "Cannot Open Jet XL ISAM registry key" - descriptive enough to find the solution.

Gray boxes when viewing Java applets

Wednesday, April 25th, 2007

Do you find you get gray boxes when you're looking at a web page with a Java applet (such as the Companies Office or JavaTester)?

You know you have the Sun JVM installed correctly, there are no traces of the Microsoft JVM, the plugin exists, but you can't see it in either Firefox or IE?

I had this problem for some time, and have finally found the cause - I have a custom transform for deploying Java, which turned off automatic updates, set the default JVM, etc, and also accepted the EULA.  As of about 1.5.0 Update 6,  setting EULA to 0 means that the JVM looks for EULA.DLL, doesn't find it, and silently dies.

Don't set the EULA property to 0 anymore. Ignore it.

You also used to be able to turn off the Automatic Updates in the properties table, but you can't any more.  You have to edit the MSI to run a registry script as the last action, and even then there are reports that Java will create the links on first-run.  I don't want my workstations getting a pop-up message saying Java will update when I carefully select the version to deploy, thanks Sun!

ProfileTool beta released

Wednesday, April 25th, 2007

ProfileTool screenshotI don't often write code, but I do find it's a good complement to cricket watching. So, in honour of New Zealand playing Sri Lanka in the World Cup semi-final, I'm proud to announce the release of the first public beta of the IT Partners ProfileTool.

ProfileTool lets you take a Windows 2000 or XP user's profile and assign it to a different user, without having to copy any files or perform any manual procedures.

This is a common task for people who are taking a network of PCs that have not been on a domain, and joining them to one; or if you replace a domain controller without keeping security information, which is sometimes done on sites upgrading from a badly installed SBS 2000 installation to a nicely installed SBS 2003 installation.

It also has useful features for deleting a profile off the disk/from the registry, and changing profiles from roaming to local, replicating the features of the User Profiles capplet.

The source is available under the Mozilla Public License, with the implication of "Do what you like with this code, but if you improve it, I'd like your source to come back to me please".

Targeting .NET 1.1 harder than it seems

Wednesday, March 21st, 2007

I'd like my application to be able to run on .NET 1.1, so I've avoided using all the new niceties of .NET 2.0.

Or so I thought.

First, I experimented with MSBee, which lets you build for the .NET 1.1 environment using the VS 2005 tools. After seeing how many errors my code generated in 1.1, while it compiled cleanly in 2.0, I thought "maybe reimplementing this in VS 2003 might be easier".
And while I've specifically avoided some of the .NET 2.0 things that would have been really handy, like the SecurityIdentifier class, which makes handling SID-account mapping easy, there's things I didn't know would be a problem. You can't set a registry key to be a certain type in 1.1. And you can't use half the features that the designer implements for you automatically. And even if you could, you'd have to hack at it, because they separate code and design with partial classes in 2.0.

So, to summarize, looks like .NET was pretty crap prior to 2005. And that means you need to have XP SP2, because it's not supported on SP1.

(/rant)

Searching and replacing attached templates in Word documents

Monday, March 19th, 2007

If you have a document take 5-15 seconds at "Requesting virus scan..." in Microsoft Word, you will think "Pesky virus scanner!". But while this fault is most commonly Norton AntiVirus, it can also manifest in another circumstance: where you have a document with an attached template on a share you can't access any more.

If you are a Windows tech, you have no excuse for not knowing about Sysinternal's Filemon - when you know exactly what an application is accessing, it lets you solve a multitude of problems, including this one. We have a customer with an application that generates Word files based on a template, in the same location as the program is being run from. Long before our involvement they appear to have had a server named "Server" (imaginitive naming) and ran the program from \\Server\Share. There is no Server any more, so the documents from that period all cause a timeout trying to find a share that doesn't exist.
Thankfully, when their current server was installed, a drive mapping was created, so all the documents from that point on are attached to a template on G:\. Therefore the task becomes to search-and-replace the template on all the old Word documents.

There is no easier way to do this than using Word's VBA, which is unfortunate, as you have to script a load of each document, which means each one takes 5-15 seconds to process. There are third party utilities I've seen that handle Word automation, but you may as well just run a macro, which appears in its full splendour below the fold.

I'd be interested to know if there was a library that let you edit Word documents, so we could do this by another method.

Net result however, documents now open speedy, and customer is happy.

(more…)

RegUnloadKey failing with error 5 (Access denied)

Sunday, March 18th, 2007

Trying to unload a registry hive and finding access is denied?

I was loading in a user hive (NTUSER.DAT in the profile), and then opening the key using RegOpenKey (exposed as Registry.Users.OpenSubKey in .NET) to prove it was successful. However, I'd forgot to close this key, so the handle was staying open and thus you couldn't unload the hive.

Oddly, after some time, the handle would clean itself up, so it seemed more like a time or permissions based issue. Simple fix however.

A working release of ProfileTool isn't far away..

Copying file permissions with robocopy

Tuesday, February 13th, 2007

I like using rsync to copy files between PCs, even on Windows. You get all the niceness of copying when the files are in use, and then only doing a small synchronization when they're not, to get a complete copy.Doesn't handle Windows file permissions well though.

Enter Robocopy (available in the Resource Kit). But I've already got the files?

robocopy source dest /s /copy:sou /is

Copies only security, owner and auditing information. Very handy.

MAPI error when sending e-mail from MYOB

Thursday, December 21st, 2006

"Cannot get the function address for MAPILogon from MAPI32.dll. Please check your MAPI installation."

Nothing on the web about this one (one other person with the same problem), but a simple fix. There is a 'fixmapi.exe' in your windows\system32 directory. Run that, and MYOB starts e-mailling fine again!

Microsysinternals releases Process Monitor

Friday, November 10th, 2006

Take Filemon and Regmon, combine them one program (apparently rewriting from scratch), and then change the license to make a previously invaluable sysadmin toolset potentially require payment. Thanks, Microsoft.

Windows utilities you didn't know about: dsacls.exe

Wednesday, October 11th, 2006

If you set permissions to lock yourself out of an object in Active Directory (or your co-worker does it for you - hi Pete!) then you can use the support tool ADSIEDIT to fix it.

Unless you've done something really difficult, like set DENY permission to "NT AUTHORITY\Authenticated Users".

The error was "An invalid directory name was passed" trying to change the properties on the object, which was also showing as a note, and not a container.

A suggestion to update the schema and clear the cache didn't work; what did work eventually, was this gem of a command line, suggested but not entirely correctly spelt out by knowledge base article 300444:

dsacls "CN=Default Global Address List,CN=All Global Address Lists,CN=Address Lists Container,CN=SITE NAME ,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=DOMAIN" /I:T /R "NT AUTHORITY\Authenticated Users"

And they say Windows isn't a CLI OS.

After using /R to remove the ACL, you can use /S to set it back to its inherited-from-parent ACL.