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. .NET (Core and Framework)
  4. CreateProcessAsUser or LogonUser

CreateProcessAsUser or LogonUser

Scheduled Pinned Locked Moved .NET (Core and Framework)
securityquestion
14 Posts 5 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.
  • B byka

    it's a console application running on a server from a scheduler. I need to start a process as specific user with access to cmd.exe and pass userID in my process

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #5

    byka wrote:

    it's a console application running on a server from a scheduler.

    The default task scheduler[^] contains options to run your app under another account. So, I assume you are not using that task-scheduler?

    byka wrote:

    I need to start a process as specific user with access to cmd.exe and pass userID in my process

    You mean that it should display a console-window where the user can execute additional commands? You don't need to start CMD just to execute an application that you would normally start using the CMD-prompt.

    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

    B 1 Reply Last reply
    0
    • L Lost User

      byka wrote:

      it's a console application running on a server from a scheduler.

      The default task scheduler[^] contains options to run your app under another account. So, I assume you are not using that task-scheduler?

      byka wrote:

      I need to start a process as specific user with access to cmd.exe and pass userID in my process

      You mean that it should display a console-window where the user can execute additional commands? You don't need to start CMD just to execute an application that you would normally start using the CMD-prompt.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

      B Offline
      B Offline
      byka
      wrote on last edited by
      #6

      Maybe this explanation will help : scheduler running under user account with no permission to C: drive. Application account should have some permission to C:drive in order to access cmd.exe I need to add code ( CreateProcessAsUser or LogonUser) for application user in order to call cmd.exe

      D L N 3 Replies Last reply
      0
      • B byka

        Maybe this explanation will help : scheduler running under user account with no permission to C: drive. Application account should have some permission to C:drive in order to access cmd.exe I need to add code ( CreateProcessAsUser or LogonUser) for application user in order to call cmd.exe

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #7

        OK, this is a bit better but there's still lots of detail missing. You're writing the scheduler app? Is this written as a standard console or Windows Forms application or is it a service? Does the application this scheduler is launching have to show up as a window that the user can type in? Why must you call CMD instead of just launching BCP directly?

        A guide to posting questions on CodeProject

        Click this: Asking questions is a skill. Seriously, do it.
        Dave Kreskowiak

        B 1 Reply Last reply
        0
        • B byka

          Maybe this explanation will help : scheduler running under user account with no permission to C: drive. Application account should have some permission to C:drive in order to access cmd.exe I need to add code ( CreateProcessAsUser or LogonUser) for application user in order to call cmd.exe

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #8

          byka wrote:

          Maybe this explanation will help

          An answer to the question would have helped too. Are you or are you not using the default task scheduler? If yes, simply define the account you want to run under in the settings.

          byka wrote:

          scheduler running under user account with no permission to C: drive. Application account should have some permission to C:drive in order to access cmd.exe

          ..sounds safer to give the user the permissions he/she actually needs. The user you are impersonating prolly has some more priviliges than just "cmd.exe".

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

          1 Reply Last reply
          0
          • B byka

            Maybe this explanation will help : scheduler running under user account with no permission to C: drive. Application account should have some permission to C:drive in order to access cmd.exe I need to add code ( CreateProcessAsUser or LogonUser) for application user in order to call cmd.exe

            N Offline
            N Offline
            Nathan Minier
            wrote on last edited by
            #9

            If you're using the default task scheduler, supply credentials that have appropriate permissions. If you've baked your own task scheduler, run it as a service, using credentials that have appropriate permissions. Either way, the wheel, axle, transmission, and engine have already been invented. You just need to paint the car.

            1 Reply Last reply
            0
            • D Dave Kreskowiak

              OK, this is a bit better but there's still lots of detail missing. You're writing the scheduler app? Is this written as a standard console or Windows Forms application or is it a service? Does the application this scheduler is launching have to show up as a window that the user can type in? Why must you call CMD instead of just launching BCP directly?

              A guide to posting questions on CodeProject

              Click this: Asking questions is a skill. Seriously, do it.
              Dave Kreskowiak

              B Offline
              B Offline
              byka
              wrote on last edited by
              #10

              You're writing the scheduler app? - Yes Is this written as a standard console or Windows Forms application or is it a service? - Consolse application Does the application this scheduler is launching have to show up as a window that the user can type in? - No Why must you call CMD instead of just launching BCP directly?- you mean call bcp.exe instead of cmd?

              D 1 Reply Last reply
              0
              • B byka

                You're writing the scheduler app? - Yes Is this written as a standard console or Windows Forms application or is it a service? - Consolse application Does the application this scheduler is launching have to show up as a window that the user can type in? - No Why must you call CMD instead of just launching BCP directly?- you mean call bcp.exe instead of cmd?

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #11

                byka wrote:

                you mean call bcp.exe instead of cmd?

                Yes

                A guide to posting questions on CodeProject

                Click this: Asking questions is a skill. Seriously, do it.
                Dave Kreskowiak

                B 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  byka wrote:

                  you mean call bcp.exe instead of cmd?

                  Yes

                  A guide to posting questions on CodeProject

                  Click this: Asking questions is a skill. Seriously, do it.
                  Dave Kreskowiak

                  B Offline
                  B Offline
                  byka
                  wrote on last edited by
                  #12

                  yes.

                  D 1 Reply Last reply
                  0
                  • B byka

                    yes.

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #13

                    That's not an answer to the question. WHY do you think you must call CMD instead of just launching BCP directly?

                    A guide to posting questions on CodeProject

                    Click this: Asking questions is a skill. Seriously, do it.
                    Dave Kreskowiak

                    1 Reply Last reply
                    0
                    • D Dave Kreskowiak

                      What kind of app are you writing and where is this process being started? Is this a Windows Forms app, console app, WPF, Windows Service, ASP.NET, ... ?? Is the process being created locally, meaning on the same machine as the code you've shown or is it being created on a remote machine? ....and you STILL do not have to run CMD and do not need the "RunAs" verb line. It's nice to see you don't listen to the answers you've been given.

                      A guide to posting questions on CodeProject

                      Click this: Asking questions is a skill. Seriously, do it.
                      Dave Kreskowiak

                      D Offline
                      D Offline
                      dreamstailoring
                      wrote on last edited by
                      #14

                      Dreams tailoring house custom make clothes for your body type, to suit unique shape size- experience pleasure of the fit you have always dream of!
                      you’re into on-trend suit designs that don’t have to huge pricetag, then dreams tailoring house is a great option.If you’re feeling really sassy,
                      get yourself into one of the dreams tailoring house suits. You’ll never look back.If you are a more reserved gentleman who only wants the best, then I recommend dreams tailoring house.
                      we are specialized in school uniforms, college uniforms, nursing uniforms,hospital uniforms,coat suits…etc.
                      <a href=http://www.kovaisuperoffer.com/ad/dreams-tailoring-house-tailoring-in-sundrapuram//</a>

                      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