Solved

ShellExecute, permissions running as service vs. desktop

Posted on 2012-04-03
8
482 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 86

Assisted Solution

by:jkr
jkr earned 250 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 250 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

717 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