简体   繁体   English

Windows Server 2008上的System.Diagnostics.Process.Start()问题

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

I need to kick off a 3rd party java application from ac# .net application. 我需要从ac#.net应用程序启动第3方Java应用程序。 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. 最初,我想从asp.net网站上执行此操作,但是在遇到权限/特权问题后,我开始尝试从Windows服务执行此操作,因为它以系统用户身份运行,希望我能解决我的问题。 Oh yes and my problems are occuring when trying to run this on a windows 2008 server. 哦,是的,尝试在Windows 2008服务器上运行此程序时出现了我的问题。 All is good in my windows 7 development environment. 在我的Windows 7开发环境中一切都很好。

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. 我可以用它来做其他事情,例如xcopy文件,也可以自己在命令行中运行命令,并且效果很好。 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. 如果我将路径(到Java二进制文件,我传递给它的文件等)更改为故意不正确的路径,则会抱怨。

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. 您必须为您的应用创建清单或关闭UAC。

What is happening is that since it is not a signed executable the UAC is preventing your service from running/starting other apps. 发生的事情是,由于它不是经过签名的可执行文件,因此UAC阻止您的服务运行/启动其他应用程序。 That's where the manifest comes in.... Look it up in the Windows SDK documentation (Applicaiton Manifest). 这就是清单的来源。...在Windows SDK文档(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) 之前我曾遇到过这样的问题,最烦人的是没有错误: http//msdn.microsoft.com/en-us/library/bb756929.aspx和此处: http : //technet.microsoft。 com / zh-CN / library / xc3tc5xx(VS.80).aspx(更好的描述)

Tutorial on manifests: http://msdn.microsoft.com/en-us/library/bb756973.aspx (Very Good) 有关清单的教程: http : //msdn.microsoft.com/zh-cn/library/bb756973.aspx(很好)

Windows App Permissions and UAC (Vista, 7, 2008/R2) http://msdn.microsoft.com/en-us/library/bb756996.aspx Windows应用程序权限和UAC(Vista,2008年7月7日,R2) http://msdn.microsoft.com/en-us/library/bb756996.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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