asp.net 웹 사이트에서 외부 응용 프로그램을 시작하는 것과 관련된 질문이 있습니다. 이제는이를 방지하기위한 보안 조치가 있다고 생각합니다. 좋은 사례는 아니지만 인트라넷 사이트의 경우이를 수행하는 데 매우 편리 할 것입니다.asp.net에서 외부 프로그램 시작
지금까지 서버를 로컬에서 (디버그로) 실행하고 있다면 외부 앱을 실행할 수있는 곳을 찾았습니다. 파일을 내 웹 서버에 게시하면 더 이상 작동하지 않습니다. 내 파일 경로가 상상할 수 없을 것이라고 생각하지만 로컬 파일이 있는지 어떻게 확인할 수 있습니까? 아니면 내가 할 수 있니?
그래서 여기 내 코드입니다 :
//the actual launch button on the page
protected void btnLaunchTnet_Click(object sender, EventArgs e)
{
string tnetpath = "c:\path\tnet.exe";
RunProcess(tnetpath, "");
}
private void RunProcess(string cmd, string arguments)
{
System.Diagnostics.Process p;
p = new System.Diagnostics.Process();
p.StartInfo.FileName = cmd;
if (arguments.Length > 1)
{
p.StartInfo.Arguments = arguments;
}
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.UseShellExecute = false;
p.Start();
}
나는 또한 비활성화하거나
private bool CheckFileExists(string filepath)
{
FileInfo SetupPath = new FileInfo(filepath);
return SetupPath.Exists;
}
@ "c : \ path \ tnet.exe"또는 "c : \\ 경로 \\ tnet.exe" – SimpleVar
그래, 내가 그랬어, 그 백 슬래시를 이스케이프하려면 tnetpath 문자열 앞에 @ 사용해야합니다 나는 그것을 복사하지 않았다. 그래도 그것을 가져 주셔서 감사합니다. – Seril