Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a .bat file I use to launch some programs. Some of them require elevated privileges (i.a. a devcon-based does-device-exist check), but some don't. So, I run the .bat as administrator, and use the runas command to run the others.

runas /trustlevel:0x20000 "C:\Folder\foo.exe"
runas /trustlevel:0x20000 "C:\Folder\bar.exe"

This works for some programs. However, for some it shows this error message (translated from Finnish by self, may be slightly different in English):

ERROR: Can not execute - bar.exe
740: The requested operation requires elevation.

The weird part is, if I create this .bat:

@echo off
start "" "bar.exe"

and run it with runas, it works like a charm. Their combination

runas /trustlevel:0x20000 "start \"\" \"C:\Folder\bar.exe\""

won't work, because start is not a file. What would cause this?

Update: I tried another command, and it worked.

runas /trustlevel:0x20000 "cmd /c start \"\" \"C:\Folder\bar.exe\""

But, what I want to know is not how to make it work but why this happens.

Update 2: As suggested in comments by and31415 this is a difference between foo.exe and bar.exe. But, there must be a difference between the ways of running them, as their results are different; that difference is what I'm looking for.

Update 3: I checked the manifests of the programs using Resource Editor, and here they are. Seems like they have the same execution level (asInvoker, which is the lowest user level).

Manifests

The upper one is bar.exe and the lower one is foo.exe. (I know, the wrong way around :D)

Update 4: Confirmed to also occur with psexec from elevated command prompt:

psexec -l -i bar.exe

gets an error,

psexec -l -i cmd /C start "" "bar.exe"

works.

share|improve this question
    
What if you run the batch file through runas? –  and31415 Feb 24 at 14:05
    
@and31415 That is exactly what I did. Read the question. –  Pietu1998 Feb 24 at 14:53
    
Considering it only happens with some programs, I think the reason why this happens boils down to the application themselves. –  and31415 Feb 24 at 15:36
    
@and31415 Now, while this is of course true, do you have any idea about what would be the difference between the ways to call the applications that causes this? –  Pietu1998 Feb 24 at 16:06
    
This is a pure speculation, but you might want to check through a resource editor whether any of those programs include a manifest, and see what the requestedExecutionLevel tag value is set to. Additionally you could test if you can reproduce the issue by the program as limited user through psexec. –  and31415 Feb 24 at 16:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.