帮助与在C#中使用CreateProcessWithLogonW [英] Help with using CreateProcessWithLogonW in C#

查看:528
本文介绍了帮助与在C#中使用CreateProcessWithLogonW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图执行与在Windows XP里面asp.net参数(C#)一个控制台应用程序。我曾尝试diagnostics.Process,但我不能得到它的工作,所以我切换到CreateProcessWithLogonW。我使用 http://www.pinvoke.net/default的code样品。 ASPX / advapi32.createprocesswithlogonw 但控制台应用程序似乎并没有运行,并从CreateProcessWithLogonW API调用的返回值是假的。

I am trying to execute a console app with arguments inside asp.net (C#) on Windows XP. I have tried diagnostics.Process but I just can't get it to work so I am switching to CreateProcessWithLogonW. I used the code sample from http://www.pinvoke.net/default.aspx/advapi32.createprocesswithlogonw but the console app doesn't seem to run and the return value from the CreateProcessWithLogonW api call is false.

我的控制台应用程序的语法是这样的:C:\\ Program Files文件\\商业智能\\ mycommand.exeARG1参数3 ARG4,如果我在DOS窗口交互运行它它运行正常。

My console app syntax is like: "C:\Program Files\business Intelligence\mycommand.exe" arg1 arg2 arg3 arg4 which runs fine if I run it interactively in a dos window.

在C#code,我之前和程序名后加上双引号。当code运行我注意到,在任务管理器的进程计数没有增加ATH第二我运行它,它告诉我的应用程序没有运行。该processInfo结构具有全部为0。

In the C# code I am adding the double quotes before and after the program name. When the code runs I noticed that the task manager processes count didn't increase ath the second I run it which tells me the app didn't run. The processInfo structure has all 0's.

我的问题:
1做了CreateProcessWithLogonW电话需要有双引号两个'命令'参数?现在我把整个命令行中的每个

My questions: 1- Do the two 'command' parameters for the 'CreateProcessWithLogonW' call need to have the double quotes? Right now I am putting the whole command line in each.

2 - 我如何捕获标准输出,所以我知道发生了什么事?

2- How do I capture the standard Output so I know what has happened?

推荐答案

本岗位为我工作。

<一个href=\"http://blogs.msdn.com/alejacma/archive/2007/12/20/how-to-call-createprocesswithlogonw-createprocessasuser-in-net.aspx\" rel=\"nofollow\">http://blogs.msdn.com/alejacma/archive/2007/12/20/how-to-call-createprocesswithlogonw-createprocessasuser-in-net.aspx

这篇关于帮助与在C#中使用CreateProcessWithLogonW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆