It is currently Tue Nov 19, 2019 2:32 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: [Solved] RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 8:05 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 393
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/all-applications-associated-with-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:
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.

Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 8:10 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1106
Location: Germany::Berlin()
Works with and without administrator rights.
Which image program is opened on your PC?

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 8:11 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 393
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 8:21 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1106
Location: Germany::Berlin()
On my PC the standard Windows program "Windows Photo Viewer" is opened.

Does this code work?
Code:
param$=""
file$="c:\temp\image.jpg"

RunProgram("rundll32.exe", Chr(34) + GetEnvironmentVariable("ProgramFiles") + "\Windows Photo Viewer\PhotoViewer.dll" + Chr(34) + ",ImageView_Fullscreen " + file$, "")

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 8:24 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1106
Location: Germany::Berlin()
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.

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 8:38 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 393
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.

Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 8:47 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1106
Location: Germany::Berlin()
Can you unfold the "shell" key? There should exist "open" and in the child key "command".

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 8:51 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 393
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:


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 10:02 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 691
Quote:
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)

_________________
(English is not my native language, I use an online translator)
Windows 10 Family x64 + Linux (Slackware, Debian on Oracle VirtualBox 6.0) + Raspberry Pi


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 11:21 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 393
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 12:59 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 691
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:

_________________
(English is not my native language, I use an online translator)
Windows 10 Family x64 + Linux (Slackware, Debian on Oracle VirtualBox 6.0) + Raspberry Pi


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 1:02 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 393
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 1:10 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 691
What about the test with another file? (in another directory)

_________________
(English is not my native language, I use an online translator)
Windows 10 Family x64 + Linux (Slackware, Debian on Oracle VirtualBox 6.0) + Raspberry Pi


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 1:18 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 393
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram fails as admin
PostPosted: Sat Jun 08, 2019 1:35 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 691
:?
Try to (re)install IrfanView (install as Admin) and set it as default image viewer.

_________________
(English is not my native language, I use an online translator)
Windows 10 Family x64 + Linux (Slackware, Debian on Oracle VirtualBox 6.0) + Raspberry Pi


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: infratec and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye