易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net如何启动服务上的应用程序 - .NET技术 / C#

由于asp.net没有权限执行一些操作,而这些操作在服务器本地是可以的,所以我想在服务器上放一个winform程序用于执行这些操作,然后通过asp.net来启动,请各位大侠赐教,感激不尽!
Process调用exe文件
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = HttpContext.Current.Server.MapPath("~/A/a.exe");
p.Start();
p.Close();

引用
Process调用exe文件
Process p = new Process();
...

这样做不行,原因是新的进程会使用(继承)调用线程的用户权限的(ASPNET干不了的它也干不了)。

可以用WindowsIdentity.Impersonate来暂时改变身份,比如换成Administrator,运行需要权限的操作后,再WindowsImpersonationContext.Undo回去。这样也不用"放一个winform程序"了。



WindowsIdentity.Impersonate是暂时转成当前登陆的windows用户的身份,如果当前用户也没有权限,就需要用以下的代码转到有权限的用户:
  private const int LOGON32_LOGON_INTERACTIVE = 2;
  private const int LOGON32_PROVIDER_DEFAULT = 0;
  private WindowsImpersonationContext impersonationContext;

[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
  private static extern bool CloseHandle(
  IntPtr handle)


相关问答:

利用C#编写txt转化到xml的程序

txt 和XML 格式相应
不借助DataSet
导入读取TXT文件
然后直接写入XML(同一文件,不同数据,递增原数据没有被覆盖情况下增加数据.)
教个要点或最好是有个代码提示的
过路好汉 帮个忙撒^^
不会,帮楼主 ......

在asp.net里面脚本出错 - .NET技术 / ASP.NET

function CheckOpwd(){//验证用户名
var pwd=document.all.txtOpwd;

var div1=document.getElementById("divPwd");

if (pwd.value=="")
{
......

asp.net导出EXCEL问题! - .NET技术 / ASP.NET

C# code:

SqlConnection conn = CsDB.sqlcon();
SqlDataAdapter da = new SqlDataAdapter("select fwCoding from bjmuma_fwCoding where OrderNumber='" + Order + & ......

求助asp.net图片上传 - .NET技术 / ASP.NET

就是一个按钮,点击之后打开对话框,然后选取图片。就这样上传。。
怎么实现。在网上搜到那么多的代码,全是很多的那种,不知道,看不下去。
所以在这里想请大哥大姐帮帮忙。

使用自带的fileupload控件可以实现 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号