Solved

ShellExecute, permissions running as service vs. desktop

Posted on 2012-04-03
8
469 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
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…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
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…

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