execting .bat file.
-
:doh:I am new to C# and .Net. I am trying to execute a bat file from inside a C# application. I continue to get a security error and no one here can help me out. Any ideas? Thanks in advance.
ProcessStartInfo pi = new System.Diagnostics.ProcessStartInfo(@"batchfile.bat", @"arguments here");
pi.UseShellExecute = true;
Process.Start(pi);Difficult, me thinks not, of couse Security Error is probably something to do with the permissions set up on your computer and I can't help you with that since I'm the Administrator on mine.
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
-
:doh:I am new to C# and .Net. I am trying to execute a bat file from inside a C# application. I continue to get a security error and no one here can help me out. Any ideas? Thanks in advance.
using Microsoft.Win32; ... string fileName = "c:\\MYBATFILE.BAT"; string args = "YOUR ARGUMENTS GO HERE"; System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents=true; proc.StartInfo.FileName=fileName; proc.StartInfo.Arguments=args; proc.Start(); proc.WaitForExit(); proc.Close();
-
using Microsoft.Win32; ... string fileName = "c:\\MYBATFILE.BAT"; string args = "YOUR ARGUMENTS GO HERE"; System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents=true; proc.StartInfo.FileName=fileName; proc.StartInfo.Arguments=args; proc.Start(); proc.WaitForExit(); proc.Close();
-
This is the error message from DOS. " The action that failed was: LinkDemand The type of first permission that failed was: System.Security.PermissionSet The demand was for: " There was more if I need to send it.. thanks in advance :doh:
The below is the entire error... Thanks and I truely appreciate any help. :doh: Unhandled Exception: System.Security.SecurityException: Request failed. at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly a sm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, Secur ityAction action, Object demand, IPermission permThatFailed) at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object ass emblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet gran ts, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Objec t assemblyOrString, SecurityAction action, Boolean throwException) at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs , PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMet hodHandle rmh, Assembly asm, SecurityAction action) at ConsoleApplication_uisftp.HelloWorld.Main() The action that failed was: LinkDemand The type of the first permission that failed was: System.Security.PermissionSet The demand was for: The granted set of the failing assembly was:
-
The below is the entire error... Thanks and I truely appreciate any help. :doh: Unhandled Exception: System.Security.SecurityException: Request failed. at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly a sm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, Secur ityAction action, Object demand, IPermission permThatFailed) at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object ass emblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet gran ts, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Objec t assemblyOrString, SecurityAction action, Boolean throwException) at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs , PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMet hodHandle rmh, Assembly asm, SecurityAction action) at ConsoleApplication_uisftp.HelloWorld.Main() The action that failed was: LinkDemand The type of the first permission that failed was: System.Security.PermissionSet The demand was for: The granted set of the failing assembly was:
are you programming in a limited xp account? is so then dont. or is this running in a secure NT network? if so... what kind of premissions do you have and what external(things other than your computer) resources are you trying to reach.
-
:doh:I am new to C# and .Net. I am trying to execute a bat file from inside a C# application. I continue to get a security error and no one here can help me out. Any ideas? Thanks in advance.
Make sure that the bat file has permission for "Everyone"