TheJoGie
treuer Stammgast
Hallo, ich möchte eine .bat Datei auf Knopfdruck starten (C#)
doch wenn ich das hier nun starte:
dann wird die Datei wenn man auf den Knopf drückt nicht ausgeführt und es wird angezeigt:
Datei nicht gefunden (oder so ähnlich, siehe Screenshot)
Das ist der Text wenn man "Ausnahmedetail in die Zwischenablage kopieren" anklickt:
PS: Sry für die blöden Fragen, bin ABSOLUTER C#-Einsteiger.
Danke im Vorraus
doch wenn ich das hier nun starte:
Code:
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("C:\\script.bat");
}
dann wird die Datei wenn man auf den Knopf drückt nicht ausgeführt und es wird angezeigt:
Datei nicht gefunden (oder so ähnlich, siehe Screenshot)
Das ist der Text wenn man "Ausnahmedetail in die Zwischenablage kopieren" anklickt:
verborgener Text:
=System.ComponentModel.Win32Exception wurde nicht behandelt. Message=Das System kann die angegebene Datei nicht finden Source=System ErrorCode=-2147467259 NativeErrorCode=2 StackTrace: bei System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) bei System.Diagnostics.Process.Start() bei System.Diagnostics.Process.Start(ProcessStartInfo startInfo) bei System.Diagnostics.Process.Start(String fileName) bei WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\Jonas\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs:Zeile 21. bei System.Windows.Forms.Control.OnClick(EventArgs e) bei System.Windows.Forms.Button.OnClick(EventArgs e) bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) bei System.Windows.Forms.Control.WndProc(Message& m) bei System.Windows.Forms.ButtonBase.WndProc(Message& m) bei System.Windows.Forms.Button.WndProc(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.Run(Form mainForm) bei WindowsFormsApplication1.Program.Main() in C:\Users\Jonas\AppData\Local\Temporary Projects\WindowsFormsApplication1\Program.cs:Zeile 18. bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ThreadHelper.ThreadStart() InnerException:
PS: Sry für die blöden Fragen, bin ABSOLUTER C#-Einsteiger.
Danke im Vorraus