c# – 外部程序执行模拟模式
我们有一个传统的CRM系统(服务器),它使用映射的网络驱动器.问题是驱动器完全打开以供任何用户修改.
我正在尝试在c#.net控制台应用程序(客户端A)中使用用户模拟. >客户端A执行.exe程序(控制台应用程序),进行模拟(域,另一个用户,密码). NETRESOURCE nr = new NETRESOURCE(); nr.dwType = ResourceType.RESOURCETYPE_DISK; nr.lpLocalName = "X:"; nr.lpRemoteName = @"x.x.x.xfolderx"; nr.lpProvider = null; int result = WNetAddConnection2(nr,null,0); >然后,控制台应用程序尝试打开位于映射网络驱动器中的.exe程序 Process ExternalProcess = new Process(); ExternalProcess.StartInfo.FileName = @"X:subfolderAPPapp.exe"; // Window application ExternalProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; ExternalProcess.Start(); ExternalProcess.WaitForExit(); 但我得到Win32Exception: Unknown error (0xfffffffe) in System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) in System.Diagnostics.Process.Start() in SecureApp.Program.Main(String[] args) en vmware-hostShared FoldersDocumentsVisual Studio 2010ProjectsSecureAppSecureAppProgram.cs:línea 142 in System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,String[] args) in System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String[] args) in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() in System.Threading.ThreadHelper.ThreadStart_Context(Object state) in System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean ignoreSyncCtx) in System.Threading.ExecutionContext.Run(ExecutionContext executionContext,Object state) in System.Threading.ThreadHelper.ThreadStart() 文件夹共享属性将模仿中使用的用户作为唯一可以阅读&写. 简而言之,我希望我的外部程序作为模拟用户执行. 编辑 这就是我想要做的事情: > Windows用户登录域 我的观点是:我可以将映射的网络驱动器仅用于作为模拟用户执行的程序,但不能用于当前登录的Windows用户吗? 解决方法
您可能希望确保网络位置是可信的:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/e4a65263-24f9-45a6-a2ad-6c26aae36075/how-to-run-net-executable-on-a-network-drive?forum=clr https://technet.microsoft.com/en-us/library/bb496428.aspx 根据您的具体情况,在本地计算机上缓存可执行文件可能是最佳选择,因为它不太容易受到网络中断的影响,并且您不必担心程序执行时从您下面发生的事情. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |