Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. execting .bat file.

execting .bat file.

Scheduled Pinned Locked Moved C#
csharphelpsecurityquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tom laz
    wrote on last edited by
    #1

    :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.

    J E S 3 Replies Last reply
    0
    • T tom laz

      :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.

      E Offline
      E Offline
      Ed Poore
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • T tom laz

        :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.

        J Offline
        J Offline
        Joshua Lunsford
        wrote on last edited by
        #3

        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();

        T 1 Reply Last reply
        0
        • J Joshua Lunsford

          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();

          T Offline
          T Offline
          tom laz
          wrote on last edited by
          #4

          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:

          T 1 Reply Last reply
          0
          • T tom laz

            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:

            T Offline
            T Offline
            tom laz
            wrote on last edited by
            #5

            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:

            J 1 Reply Last reply
            0
            • T tom laz

              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:

              J Offline
              J Offline
              Joshua Lunsford
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • T tom laz

                :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.

                S Offline
                S Offline
                Spike Blue Heaven
                wrote on last edited by
                #7

                Make sure that the bat file has permission for "Everyone"

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups