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)
相关问答:
可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......
C# code: SqlConnection conn = CsDB.sqlcon(); SqlDataAdapter da = new SqlDataAdapter("select fwCoding from bjmuma_fwCoding where OrderNumber='" + Order + & ......
本人工作经验一年以上 熟悉asp.net 熟悉javascript 熟悉Css 熟悉ajax 熟悉sqlserver2005 有一年的项目经验 具体项目和其他的就不在这写了 有意者联系: QQ:359233910 引用 本人工作经验一年以上 熟悉asp ......
A表 有两个字段 id 唯一数字域 InfoTxt text 类型 我现在要把 id 不是14 的所有 InfoTxt字段 文本后面 都加上 'aaa' 按下面执行下来 只有表最后一行加上了 'aaa' ......