?
Solved

ShellExecute, permissions running as service vs. desktop

Posted on 2012-04-03
8
Medium Priority
?
489 Views
Last Modified: 2012-04-09
Hi

I have a VC++ 6.0 application on Windows7 32bit that can be run as a GUI app direct from the desktop, or it can be run as a service using the "srvany" tool, which is how it is normally running.

One contained method of the application calls ShellExecute() to run a command line compression tool.

If I run the EXE from the desktop, logged in as administrator the call to ShellExecute runs as expected.

If however it is running as a service (configured for Local System login) then the call fails (hangs indefinitely)

The service did not used to fail though, until I put the computer in question onto a different domain. Now it does fail.

It must be a permissions thing, but which? I have tried adding network service, local service, "everybody" with full control rights to all of the folders I can think of to no avail.

Any thoughts?

Thanks
0
Comment
Question by:PMH4514
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 10

Expert Comment

by:CSI-Windows_com
ID: 37803195
It sounds like a job for Procmon. (http://live.sysinternals.com/procmon.exe).

If you create a procmon log and upload it to wetransfer.com, I will take a look for you.

You want to start procmon and then immediately issue a service start.

Once you know the error condition has occurred, immediately stop procmon monitoring.

Do a file save and zip the *.PML file before uploading.

You can contact me at http://csi-windows.com/contactus and I will respond with the email address to send the wetransfer notification to.
0
 
LVL 86

Expert Comment

by:jkr
ID: 37803569
What happens if you run the service as an account different to LocalSystem?
0
 

Author Comment

by:PMH4514
ID: 37803824
Ok I figured it out I think.

When I ran the EXE from the desktop, when it tried to run the "7z.exe" (the compression utility) I saw a windows message warning me that it was not a trusted. I believe from the service this same dialog was probably running but without desktop access enabled, it hung..

When I then clicked the checkbox "don't show me this again", subsequent attempts while running as a service succeeded.
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 86

Assisted Solution

by:jkr
jkr earned 1000 total points
ID: 37803877
Hmm, instead of reying on 3rd party tools, take a look at http://www.codeproject.com/Articles/4135/XZip-and-XUnzip-Add-zip-and-or-unzip-to-your-app-w ("XZip and XUnzip - Add zip and/or unzip to your app with no extra .lib or .dll") on how to do that in code, e.g.

HZIP hz = CreateZip("test.zip",0,ZIP_FILENAME);

  ZipAdd("test1.txt","test1.txt",0,ZIP_FILENAME);
  ZipAdd("test2.txt","test2.txt",0,ZIP_FILENAME);

  CloseZip(hz);

Open in new window

0
 
LVL 10

Accepted Solution

by:
CSI-Windows_com earned 1000 total points
ID: 37804446
Doh,
I forgot this until now.  If you ever suspect that  service is popping up a message when running under Windows 7, enable a service called "Interactive Services Detection" and it will tell you a service is trying to display a message and ask if you want to see it.

What you have found makes sense since the marker that triggers the Open File Security Warning for a downloaded file is actually stored in the file itself.
0
 
LVL 86

Expert Comment

by:jkr
ID: 37804466
That's why I'd *never* trust any 3rd party program being launched by a service, especially if the task it has to perform can easily be done in your own code as well.
0
 

Author Comment

by:PMH4514
ID: 37808751
thanks JKR I wasn't aware of that XZip ability. I always figured "zip" was tried and true, why even think of reinventing that wheel.

The Interactive Services Detection comment by @CSI-Windows_com is a nice reference for me as well..  

I'm gonna split points between you both unless anybody objects!
0
 
LVL 86

Expert Comment

by:jkr
ID: 37808792
No objection ;o)
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question