Process.Start和“系统找不到指定的路径". [英] Process.Start and "The system cannot find the path specified"

查看:95
本文介绍了Process.Start和“系统找不到指定的路径".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从映射驱动器(T:\是共享网络文件夹的映射驱动器)运行控制台应用程序,并得到错误消息:

I am trying to run a console application from a mapped drive (T:\ is a mapped drive for a shared network folder) and get the error:

系统找不到指定的路径.

The system cannot find the path specified.

为什么会出现此错误?管理员凭据正确.

Why do I get this error? The administrator credentials are correct.

var password = new SecureString();
password.AppendChar(Convert.ToChar("P"));
password.AppendChar(Convert.ToChar("a"));
password.AppendChar(Convert.ToChar("a"));
password.AppendChar(Convert.ToChar("s"));
Process.Start(@"t:\ca\test.exe"), "", "Administrator", password, "domain");

推荐答案

检查是否为 Administrator 帐户正确映射了映射的驱动器 T:.

Check if the mapped drive T: is also correctly mapped for the Administrator account.

我也不确定,但是可能必须登录管理员才能使映射的驱动器可用.

Also, I'm not sure, but the Administrator must probably be logged in for the mapped drive to be available.

您还可以尝试以下操作,从 cmd.exe 开始,映射UNC路径,然后调用应用程序:

You could also try the following, starting cmd.exe, mapping your UNC path and then calling the application:

var password = new SecureString();
password.AppendChar(Convert.ToChar("P"));
password.AppendChar(Convert.ToChar("a"));
password.AppendChar(Convert.ToChar("a"));
password.AppendChar(Convert.ToChar("s"));

var startInfo = new ProcessStartInfo();

startInfo.FileName = "cmd.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.UserName = "Administrator";
startInfo.Password = password;
startInfo.Domain = "domain";

var process = Process.Start(startInfo);

process.BeginOutputReadLine();
process.StandardInput.WriteLine(@"pushd \\your_unc_path\ca");
process.StandardInput.WriteLine("test.exe");
process.StandardInput.WriteLine("exit");

process.WaitForExit();

这篇关于Process.Start和“系统找不到指定的路径".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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