[Solved] RunProgram fails as admin

Just starting out? Need help? Post your questions and find answers here.
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

[Solved] RunProgram fails as admin

Post by BarryG »

Solved! :) I noticed that when I was logged in as admin, my default apps were set to something called "TWINUI". So I googled that, and found this thread:

https://superuser.com/questions/1150365 ... ith-twinui

A little down the page of that link, was a PowerShell script to "reset" the apps to their Win 10 defaults:

https://github.com/WillBixler/TwinUI-Fix

So I downloaded the script and ran it (hoping it wasn't malicious!) and it removed the "TWINUI" defaults and put them back to the correct Win 10 defaults. From there, I was able to change those defaults back to IrfanView (for images) and Media Player Classic (for MP4s).

The end result: my app now runs (opens) the files correctly when run as admin! :D

Original post:

Got a weird one for you. The following line fails to open a JPG image when my exe is run with admin rights, but opens it normally when run with limited rights. What the hell? What could be causing it to fail with admin rights? :shock: The result of RunProgram() is 1, so the command "worked", but no image is opened. I tried disabling my anti-virus (Windows Defender) but it didn't make any difference.

Code: Select all

param$=""
file$="c:\temp\image.jpg"
RunProgram(file$,param$,GetPathPart(file$))
[Edit] I even got this Windows message when trying to run it as admin, so it has to be some sort of permission thing? My program works fine on another PC. Wish I knew why one PC has the issue, though. How can I expect my customers to deal with a problem like this?

Image
Last edited by BarryG on Sat Jun 08, 2019 1:35 pm, edited 4 times in total.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: RunProgram fails as admin

Post by RSBasic »

Works with and without administrator rights.
Which image program is opened on your PC?
Image
Image
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: RunProgram fails as admin

Post by BarryG »

IrfanView. It's so weird, isn't it? Such a simple command and snippet. I'm shocked. Maybe it's a permission thing. Even ShellExecute_() won't open it when run as admin.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: RunProgram fails as admin

Post by RSBasic »

On my PC the standard Windows program "Windows Photo Viewer" is opened.

Does this code work?

Code: Select all

param$=""
file$="c:\temp\image.jpg"

RunProgram("rundll32.exe", Chr(34) + GetEnvironmentVariable("ProgramFiles") + "\Windows Photo Viewer\PhotoViewer.dll" + Chr(34) + ",ImageView_Fullscreen " + file$, "")
Image
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: RunProgram fails as admin

Post by RSBasic »

Check the opening path: HKEY_CLASSES_ROOT\jpegfile\Shell\open\command
What's the path?
You can open the file with the path entered in the registry.
Image
Image
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: RunProgram fails as admin

Post by BarryG »

Hi RSBasic, opening with your code snippet works perfectly as limited and admin. :)

There's no Registry entry for what you posted (see below). But why does limited open it, but not admin?

Image
Last edited by BarryG on Sat Jun 08, 2019 8:50 am, edited 1 time in total.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: RunProgram fails as admin

Post by RSBasic »

Can you unfold the "shell" key? There should exist "open" and in the child key "command".
Image
Image
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: RunProgram fails as admin

Post by BarryG »

Nothing under it when expanded. See edited post above with new image.

And it's not just that: when running as limited, PDFs open with SumatraPDF; but when I run as admin, PDFs open with Edge. :shock:
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: RunProgram fails as admin

Post by Marc56us »

Got a weird one for you. The following line fails to open a JPG image when my exe is run with admin rights, but opens it normally when run with limited rights. What the hell? What could be causing it to fail with admin rights? :shock: The result of RunProgram() is 1, so the command "worked", but no image is opened. I tried disabling my anti-virus (Windows Defender) but it didn't make any difference.
First of all, verify Property of file (image.jpg) and parent folder (c:\temp\) (security and owner)
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: RunProgram fails as admin

Post by BarryG »

Marc56us wrote:First of all, verify Property of file (image.jpg) and parent folder (c:\temp\) (security and owner)
Folder and files inside all have full access rights for all users.
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: RunProgram fails as admin

Post by Marc56us »

This message is a Windows System Message.
Sometime it's due to a corrupted filesystem. This is often the case for illogical behaviour on file access.
:arrow: Check hard drive. (properties, second tab)

Does it occure with another file ? (on another disk drive) (I guess you've already tested it, but just in case...)

:wink:
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: RunProgram fails as admin

Post by BarryG »

Checked hard drive (SSD), no errors found. It's fairly new, too. The only difference is admin vs limited rights for my process, so wouldn't that rule out any SSD errors?
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: RunProgram fails as admin

Post by Marc56us »

What about the test with another file? (in another directory)
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: RunProgram fails as admin

Post by BarryG »

Marc56us wrote:What about the test with another file? (in another directory)
Nope. All JPGs (and MP4s) in other folders won't run from admin either. Only from limited. This bites.
Post Reply