어떻게 C#을 사용하여 응용 프로그램을 시작할 수 있습니까?C#에서 응용 프로그램 (.EXE)을 시작 하시겠습니까?
요구 사항 : Windows XP 및 Windows Vista에서 작동해야합니다.
Windows에서만 작동하는 DinnerNow.net 샘플러의 샘플을 보았습니다. Vista.
어떻게 C#을 사용하여 응용 프로그램을 시작할 수 있습니까?C#에서 응용 프로그램 (.EXE)을 시작 하시겠습니까?
요구 사항 : Windows XP 및 Windows Vista에서 작동해야합니다.
Windows에서만 작동하는 DinnerNow.net 샘플러의 샘플을 보았습니다. Vista.
System.Diagnostics.Process.Start()
방법을 사용하십시오.
사용 방법은 this article을 확인하십시오. http://en.wikipedia.org/wiki/Environment_variable#Default_Values_on_Microsoft_Windows
예 :
System.Diagnostics.Process.Start("PathToExe.exe");
또한 당신은 가능한 모든 경우에 당신의 경로에 대한 환경 변수를 사용하는 것이 좋습니다
긴 목록에 대한 링크가 더 많습니다. ProcessStartInfo, Process : 훨씬 더 이러한 개체로 할 수있다
using System.Diagnostics;
// Prepare the process to run
ProcessStartInfo start = new ProcessStartInfo();
// Enter in the command line arguments, everything you would enter after the executable name itself
start.Arguments = arguments;
// Enter the executable to run, including the complete path
start.FileName = ExeName;
// Do you want to show a console window?
start.WindowStyle = ProcessWindowStyle.Hidden;
start.CreateNoWindow = true;
int exitCode;
// Run the external process & wait for it to finish
using (Process proc = Process.Start(start))
{
proc.WaitForExit();
// Retrieve the app's exit code
exitCode = proc.ExitCode;
}
, 당신은 문서를 읽어야
여기에 도움이 코드의 조각입니다.
그냥 .exes 이외의 다른 파일 형식에서도 작동하는 것 같습니다. 열려고하는 파일을 가리키면 열리면 Windows가 열 것입니다. System.Diagnostics.Process.Start (@ "C : \ Users \ Blank \ Desktop \ PdfFile.pdf"); – DLeh
WindowStyle = ProcessWindowStyle.Hidden은 비 GUI 용입니다.처음 실행했을 때 UseShellExecute = false없이 실패했지만 지금은 작동합니다. 거기에 무슨 일이 일어나고 있는지 확실하지 않습니다 ... – Barton
진실로, 나는 GUI 애플 리케이션으로 이것을 시도한 적이 없다. – sfuqua
System.Diagnostics.Process.Start(@"C:\Windows\System32\Notepad.exe");
당신이 내가 가진처럼, 그것없이 작동합니다 다음과 같은 간단한 코드를 사용 System.Diagnostics 네임을 사용하는 데 문제가있는 경우 : 프로세스를 시작
Process notePad = new Process();
notePad.StartInfo.FileName = "notepad.exe";
notePad.StartInfo.Arguments = "mytextfile.txt";
notePad.Start();
"System.Diagonostics가없는"이 기능은 무엇입니까? '프로세스 '는 System.Diagnostics에 있습니다. –
사용 Process.Start를합니다.
using System.Diagnostics;
class Program
{
static void Main()
{
//
// your code
//
Process.Start("C:\\process.exe");
}
}
는 그냥 \ 빈 \ Debug 폴더에 file.exe가 넣어 사용하십시오
Process.Start("File.exe");
당신의 대답은 이전의 것들 모두에서 어떻게 개선됩니까? – mustaccio
을이 :
Process.Start("Location Of File.exe");
(당신이 열고 System.Diagnostics 라이브러리를 사용하는지 확인)
아담 케인
System.Diagnostics.Process.Start(@"C:\Windows\System32\Notepad.exe");
위대한 작품 !!!!!
exe의 전체 이름을 모르는 경우 "PathTo * .exe"를 호출하려고합니다. 이것이 가능합니까? – vishal