We use batch files to do simple installations of COM servers - mainly a few file copies and regsvr32s. Since regsvr32 writes to the registry's local machine hive, the batch must be run with administrative privileges. I'd like to be able to recognize when this is not the case, and let the user know before the installation fails.
A possible solution would be to try to create a file in system32, and then check if it exists. If it does, the user most probably (always?) has permissions to write to the registry as well. Otherwise, let the user know the installation will fail. However, I'm not sure how accurate the check is - I don't really want to be able to create (and then delete) files in system32, just install a COM server. Is there a better way?
The problem is most common with Windows 7 and 2008 - if there's a solution that will only work for them, so be it. I would, however, like to keep using simple batch files.