简体   繁体   中英

System.Diagnostics.Process.Start() problems on Windows Server 2008

I need to kick off a 3rd party java application from ac# .net application. Originally I wanted to do this from an asp.net site but after running into problems with permissions/privileges I moved onto attempting to do it from a windows service since it runs as the system user which I'd hoped would remove my problems. Oh yes and my problems are occuring when trying to run this on a windows 2008 server. All is good in my windows 7 development environment.

Naturally I have scoured these forums and others for answers and nothing I have found has helped so please entertain me.

I have the command I want to run in a batch file and am using the following code to start it.

ProcessStartInfo psi = new ProcessStartInfo(filePathToBatchFile);
        psi.Arguments = "arguments for batch file..."
        psi.UseShellExecute = false;
        psi.RedirectStandardOutput = true;
        psi.RedirectStandardError = true;
        psi.RedirectStandardInput = true;
        Process p = Process.Start(psi);

I'm running a batch file essentially because I wanted to make sure that something was happening. I have made sure that all the variables and file paths are correct and that the batch file is indeed running. I can get it to do other things like xcopy files around and I can run the command myself from the command line and it works fine. There are no exceptions being thrown and no output from the process. If I changed the paths (to the java binaries, the files that I'm passing to it etc.) to deliberately incorrect ones then it complains.

I have tried running this process as different users, namely the one I can use to log into the server and run the command manually. I have given the service access to the desktop from the services properties menu.

If anyone has any ideas about what is happening here, or even some tips on how I can go about diagnosing this it would be hugely appreciated.

You have to create a manifest for your app or turn off UAC.

What is happening is that since it is not a signed executable the UAC is preventing your service from running/starting other apps. That's where the manifest comes in.... Look it up in the Windows SDK documentation (Applicaiton Manifest).

I have ran into issues like this before, and whats most annoying is that there are no errors: http://msdn.microsoft.com/en-us/library/bb756929.aspx and here: http://technet.microsoft.com/en-us/library/xc3tc5xx(VS.80).aspx (better description)

Tutorial on manifests: http://msdn.microsoft.com/en-us/library/bb756973.aspx (Very Good)

Windows App Permissions and UAC (Vista, 7, 2008/R2) http://msdn.microsoft.com/en-us/library/bb756996.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM