From: GLENN R. <rh...@dr...> - 2010-02-24 18:28:58
|
On Tue, 23 Feb 2010 22:57:30 +0200 Tor Lillqvist <tm...@ik...> wrote: > >> Run the program from cmd.exe and you will see a more helpful > message. > > > I did and the program worked correctly! > > Oh? Even if it was called "patcher.exe"? I expected you to get a UAC > (User Account Control) dialog in that case. ("Do you want to let this > program from an unknown publisher make changes to this computer" or > something like that.) I just tried it and that's what happened. When you answer yes/allow, the program works correctly. > That is what happens for me, if I have a program called > "patcher.exe": > When run from MSYS I just get "Bad file number", from cmd.exe the UAC > dialog. Possibly some caching is involved, if you have been renaming > files back and forth Windows might be confused by now;) > > What a program *actually* does, what code it contains, is irrelevant > for the triggering of the UAC dialog as far as I know, it is just the > *name* that matters. I didn't think the problem had anything to do with my code (particularly, when a do-nothing program has the same problem). > Note that if you have a program with some random > "safe" name and it tries to do some "administrative" operations to > the > computer, you won't get this dialog when you run it, but if you run > it > without administrative privileges such operations won't succeed, of > course. > > I.e. my point was that the name "patcher" makes Windows assume it is > a > program that needs administrative privileges and thus Windows > helpfully asks for permission to provide them to the program; for > some > reason this doesn't happen when the program is run from the MSYS > shell. Anyway, the way around this "useful" feature is to provide a > .manifest file for the program that tells Windows that no privilege > elevation is necessary (i.e. even if the program name contains > "patch" > it doesn't actually do anything that would require administrative > privileges). > > The .manifest file should look like this: > > <?xml version="1.0" encoding="UTF-8" standalone="yes"?> > <assembly xmlns="urn:schemas-microsoft-com:asm.v1" > manifestVersion="1.0"> > <v3:trustInfo xmlns:v3="urn:schemas-microsoft-com:asm.v3"> > <v3:security> > <v3:requestedPrivileges> > <v3:requestedExecutionLevel level="asInvoker" /> > </v3:requestedPrivileges> > </v3:security> > </v3:trustInfo> > </assembly> > > and for patcher.exe, it should be called patcher.exe.manifest . I had > to create such files for MSYS's install.exe and patch.exe back when I > switched to Windows 7 from XP. (By now presumably MSYS presumably > comes with manifests for these exes?) And also for a program called > gtk-update-icon-info.exe for instance. > > --tml I never suspected the file name had anything to do with it. If that's the case, then it seems easiest just to rename the file to something that doesn't contain "patch". -- Glenn |