ProcessStartInfo不使用IIS 7 [英] ProcessStartInfo Not Working with IIS 7

查看:133
本文介绍了ProcessStartInfo不使用IIS 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我用以下代码创建了一个网站



/ *以下代码只需访问 - 打开100.20.20.20具有特定凭证的IP并允许使用(System.Diagnostics.Process proc = new System.Diagnostics.Process())访问文件--- START * /



{

proc.StartInfo.FileName =cmd;

proc.StartInfo.Arguments = @/ c net use \\100.20.20.20\d $ / user:testuser testpwd;

proc.StartInfo.UseShellExecute = false;

proc.Start();

}

/ * -END * /

/ *以下代码将尝试从给定路径运行exe * /

System.Diagnostics.ProcessStartInfo procStartInfo = new System。 Diagnostics.ProcessStartInfo();

procStartInfo.RedirectStandardOutput = true;

procStartInfo.UseShellExecute = false;

procStartInfo.FileName =notepad;

procStartInfo.Arguments = @\\100.20.20.20\d $ \\\test.txt;

procStartInfo.CreateNoWindow = true;

procStartInfo.Verb =runas;

using(System.Diagnostics.Process proc = new System.Diagnostics.Process())

{

proc.StartInfo = procStartInfo;

proc.Start();

}



当我运行视觉学习2010 - asp.net的代码时,它运行正常,它正在从给定的IP地址正确打开记事本 - test.txt。



但是当我在IIS 7.0上托管相同的应用程序时,没有结果,没有错误,不知道幕后发生了什么......



尝试以下备用解决方案但没有运气:(。



1)给定网络服务默认应用程序的所有权利p IIS 7上的ool

2)给予网络服务的虚拟目录的完全权限。

3)给予包含此测试文件夹的文件夹的完全权限。



如果有人知道请帮帮我

先谢谢你...

解决方案

/ user:testuser testpwd;

proc.StartInfo.UseShellExecute = false;

proc.Start();

}

/ * -END * /

/ *以下代码将尝试从给定路径运行exe * /

System.Diagnostics.ProcessStartInfo procStartInfo = new System .Diagnostics.ProcessStartInfo();

procStartInfo.RedirectStandardOutput = true;

procStartInfo.UseShellExecute = false;

procStartInfo.FileName =notepad ;

procStartInfo.Arguments = @\\100.20.20.20\d


\test\test.tx t;

procStartInfo.CreateNoWindow = true;

procStartInfo.Verb =runas;

using(System.Diagnostics.Process proc = new System.Diagnostics.Process())

{

proc.StartInfo = procStartInfo;

proc.Start();

}



当我运行视觉学习2010 - asp.net的代码时,它运行正常,它打开记事本 - test.txt从给定的IP地址正确。



但是当我在IIS 7.0上托管相同的应用程序时,没有结果,没有错误,不知道幕后发生了什么..



尝试以下替代解决方案但没有运气:(。



1)鉴于网络服务IIS 7上默认应用程序池的所有权利

2)给予网络服务虚拟目录的完全权限。

3)给予包含文件夹的完全权限这个测试文件夹。



如果有人知道请帮助我

提前致谢...


< blockquote>一些方法:

1)使用内置的线程池用户:创建一个专门的技术用户。它也更安全和其他原因。
(您可以设置池加载用户配置文件,它有很多优点,例如您可以从服务器端的asp.net打印)

2)如何访问远程资源

a)如果您在域中,此技术用户可以是域用户,因此默认情况下存在跨服务器信任

b)如果技术用户是本地用户,请忘记调用cli,尝试使用此权限访问远程共享: UNCAccess [ ^ ]

c)您只能为执行的一部分冒充用户:用于冒充用户的小型C#类 [ ^ ]

3)您甚至可以以模拟用户的名义开始处理,请参阅: http://support.microsoft.com/kb/889251 [ ^ ]


Hi,
I have created one website with the following code

/* Following code will just access - open 100.20.20.20 Ip with specific credential and allow to access file --- START */
using (System.Diagnostics.Process proc = new System.Diagnostics.Process())
{
proc.StartInfo.FileName = "cmd";
proc.StartInfo.Arguments = @"/c net use \\100.20.20.20\d$ /user:testuser testpwd";
proc.StartInfo.UseShellExecute = false;
proc.Start();
}
/* -END */
/* Following code will try to run exe from the given path */
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo();
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.FileName = "notepad";
procStartInfo.Arguments = @"\\100.20.20.20\d$\test\test.txt";
procStartInfo.CreateNoWindow = true;
procStartInfo.Verb = "runas";
using (System.Diagnostics.Process proc = new System.Diagnostics.Process())
{
proc.StartInfo = procStartInfo;
proc.Start();
}

When I run above code from visual studion 2010 - asp.net , it is running fine , It''s opening notepad - test.txt properly from the given IP address.

But when Same application i host on IIS 7.0 then no result , no error , do not know what''s happening behind the scene..

Tried with the following alternate solution But no luck :(.

1) Given Network Service All rights to the default app pool on IIS 7
2) Given full rights to the Virtual Directory for network Service.
3) Given full rights to the folder which contain this test folder.

Please help me if anyone know
Thanks in Advance...

解决方案

/user:testuser testpwd";
proc.StartInfo.UseShellExecute = false;
proc.Start();
}
/* -END */
/* Following code will try to run exe from the given path */
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo();
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.FileName = "notepad";
procStartInfo.Arguments = @"\\100.20.20.20\d


\test\test.txt";
procStartInfo.CreateNoWindow = true;
procStartInfo.Verb = "runas";
using (System.Diagnostics.Process proc = new System.Diagnostics.Process())
{
proc.StartInfo = procStartInfo;
proc.Start();
}

When I run above code from visual studion 2010 - asp.net , it is running fine , It''s opening notepad - test.txt properly from the given IP address.

But when Same application i host on IIS 7.0 then no result , no error , do not know what''s happening behind the scene..

Tried with the following alternate solution But no luck :(.

1) Given Network Service All rights to the default app pool on IIS 7
2) Given full rights to the Virtual Directory for network Service.
3) Given full rights to the folder which contain this test folder.

Please help me if anyone know
Thanks in Advance...


Some approaches:
1) use a thread pool user other than the built-in ones: create a dedicated technical user. It is better for security and other reasons too.
(you could set the pool to load user profile too, there are many advantages of it, for example you can print from asp.net on server side)
2) how to access remote resources
a) if you are in a domain, this technical user can be a domain user, thus cross-server trust is there by default
b) if the technical user is local, forget calling cli, try this one to access remote share: UNCAccess[^]
c) you can impersonate a user only for a portion of the execution: A small C# Class for impersonating a User[^]
3) you can even start process in the name of the impersonated user, see: http://support.microsoft.com/kb/889251[^]


这篇关于ProcessStartInfo不使用IIS 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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