?
Solved

ShellExecute, permissions running as service vs. desktop

Posted on 2012-04-03
8
Medium Priority
?
514 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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.
Suggested Courses

862 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