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. Permission problem with System.Diagnostics.Process.GetProcesses(MachineName)

Permission problem with System.Diagnostics.Process.GetProcesses(MachineName)

Scheduled Pinned Locked Moved C#
helptutorial
15 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.
  • C Offline
    C Offline
    crash893
    wrote on last edited by
    #1

    Hi all, whenever use this little section of code i get a permission error. I have admin rights to all the boxes i want to check but im not sure how to pass admin credentials to the machines to can get use the GetProcesses method code follows: foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcesses(MachineName)) { try { textBox3.AppendText("Proc Name: " + proc.ProcessName.ToString() + " @ " + proc.StartTime.ToString() + "\n"); } catch { } }

    S D D 3 Replies Last reply
    0
    • C crash893

      Hi all, whenever use this little section of code i get a permission error. I have admin rights to all the boxes i want to check but im not sure how to pass admin credentials to the machines to can get use the GetProcesses method code follows: foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcesses(MachineName)) { try { textBox3.AppendText("Proc Name: " + proc.ProcessName.ToString() + " @ " + proc.StartTime.ToString() + "\n"); } catch { } }

      S Offline
      S Offline
      Sathesh Sakthivel
      wrote on last edited by
      #2

      What Permission Error it says?

      Regards, Satips.:rose:

      C 1 Reply Last reply
      0
      • S Sathesh Sakthivel

        What Permission Error it says?

        Regards, Satips.:rose:

        C Offline
        C Offline
        crash893
        wrote on last edited by
        #3

        Couldn't connect to remote machine

        S C 2 Replies Last reply
        0
        • C crash893

          Couldn't connect to remote machine

          S Offline
          S Offline
          Sathesh Sakthivel
          wrote on last edited by
          #4

          Try with LOGON32_LOGON_NETWORK (value 3) as LogonType, the token returned by LogonUser is an "impersonation token", such a token CANNOT be used in WindowsIdentity.Impersonate() in order to access network resources. Then go with the code.

          Regards, Satips.:rose:

          C 1 Reply Last reply
          0
          • C crash893

            Couldn't connect to remote machine

            C Offline
            C Offline
            crash893
            wrote on last edited by
            #5

            System.Diagnostics.Process[] ipByName = System.Diagnostics.Process.GetProcessesByName("notepad", "192.168.1.19"); Ive also tried something like this

            1 Reply Last reply
            0
            • S Sathesh Sakthivel

              Try with LOGON32_LOGON_NETWORK (value 3) as LogonType, the token returned by LogonUser is an "impersonation token", such a token CANNOT be used in WindowsIdentity.Impersonate() in order to access network resources. Then go with the code.

              Regards, Satips.:rose:

              C Offline
              C Offline
              crash893
              wrote on last edited by
              #6

              i understand the idea kinda of but how would i put that into code ( i will be off googleing this but if you have an example handy i could use the help)

              1 Reply Last reply
              0
              • C crash893

                Hi all, whenever use this little section of code i get a permission error. I have admin rights to all the boxes i want to check but im not sure how to pass admin credentials to the machines to can get use the GetProcesses method code follows: foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcesses(MachineName)) { try { textBox3.AppendText("Proc Name: " + proc.ProcessName.ToString() + " @ " + proc.StartTime.ToString() + "\n"); } catch { } }

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

                Are all these machines in the same domain, or is this a Workgroup environment? If domain, then the code has to run under an admin account that the domain trusts. If workgroup, then the Admin account username AND password must match those on the machine that's running your code, exactly, meaning exact same username and exact same password. This really isn't caused by a problem in your code. It's more of an understanding of how Windows networking works.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007

                C 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  Are all these machines in the same domain, or is this a Workgroup environment? If domain, then the code has to run under an admin account that the domain trusts. If workgroup, then the Admin account username AND password must match those on the machine that's running your code, exactly, meaning exact same username and exact same password. This really isn't caused by a problem in your code. It's more of an understanding of how Windows networking works.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                       2006, 2007

                  C Offline
                  C Offline
                  crash893
                  wrote on last edited by
                  #8

                  its a domain i am an admin to my machine and my log on gives me admin rights to all the computers i need to access also i know the cred's to THE admin account across all the computers from my session on my laptop i can see and access all the computers (\\usat-whatever\c$\whatever)

                  D 1 Reply Last reply
                  0
                  • C crash893

                    Hi all, whenever use this little section of code i get a permission error. I have admin rights to all the boxes i want to check but im not sure how to pass admin credentials to the machines to can get use the GetProcesses method code follows: foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcesses(MachineName)) { try { textBox3.AppendText("Proc Name: " + proc.ProcessName.ToString() + " @ " + proc.StartTime.ToString() + "\n"); } catch { } }

                    D Offline
                    D Offline
                    devesh_code
                    wrote on last edited by
                    #9

                    Hello Have you got the solution of your problem...if yes then plz tell me because i am facing the same problem... Thanks

                    Devesh Mishra

                    C 1 Reply Last reply
                    0
                    • D devesh_code

                      Hello Have you got the solution of your problem...if yes then plz tell me because i am facing the same problem... Thanks

                      Devesh Mishra

                      C Offline
                      C Offline
                      crash893
                      wrote on last edited by
                      #10

                      nope

                      1 Reply Last reply
                      0
                      • C crash893

                        its a domain i am an admin to my machine and my log on gives me admin rights to all the computers i need to access also i know the cred's to THE admin account across all the computers from my session on my laptop i can see and access all the computers (\\usat-whatever\c$\whatever)

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

                        Well, you need an account that gives you admin rights to all the machines. Your code is saying that the account it's running under doesn't have it. Just having access to the hidden shares on the machines isn't enough.

                        A guide to posting questions on CodeProject[^]
                        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                             2006, 2007

                        C 1 Reply Last reply
                        0
                        • D Dave Kreskowiak

                          Well, you need an account that gives you admin rights to all the machines. Your code is saying that the account it's running under doesn't have it. Just having access to the hidden shares on the machines isn't enough.

                          A guide to posting questions on CodeProject[^]
                          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                               2006, 2007

                          C Offline
                          C Offline
                          crash893
                          wrote on last edited by
                          #12

                          well i do know the "administrator" and its password account for each box i need how would i pass that to the machine -- modified at 9:19 Monday 18th June, 2007 for example lets say i usually log in as User:administrator Pass:crash893 to the local machine how would i pass that too the get proccess method so that the computer on the other end would know its me?

                          D 1 Reply Last reply
                          0
                          • C crash893

                            well i do know the "administrator" and its password account for each box i need how would i pass that to the machine -- modified at 9:19 Monday 18th June, 2007 for example lets say i usually log in as User:administrator Pass:crash893 to the local machine how would i pass that too the get proccess method so that the computer on the other end would know its me?

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

                            Well, it might be you can do something like:

                            System.Threading.Thread.CurrentThread.CurrentPrinciple = New System.Net.NetworkCredential("user","pw")
                            

                            or something along those lines. I HAVE NO IDEA IF THIS WILL WORK!! I HAVE NOT TESTED IT AND DON'T HAVE AN ENVIRONMENT TO TRY IT IN!!

                            A guide to posting questions on CodeProject[^]
                            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                                 2006, 2007

                            C 1 Reply Last reply
                            0
                            • D Dave Kreskowiak

                              Well, it might be you can do something like:

                              System.Threading.Thread.CurrentThread.CurrentPrinciple = New System.Net.NetworkCredential("user","pw")
                              

                              or something along those lines. I HAVE NO IDEA IF THIS WILL WORK!! I HAVE NOT TESTED IT AND DON'T HAVE AN ENVIRONMENT TO TRY IT IN!!

                              A guide to posting questions on CodeProject[^]
                              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                                   2006, 2007

                              C Offline
                              C Offline
                              crash893
                              wrote on last edited by
                              #14

                              that looks very promising i will try it at work tommrow would i run that at form load? or in the event? edit did you mean CurrentCulture i dont see anything else close?

                              C 1 Reply Last reply
                              0
                              • C crash893

                                that looks very promising i will try it at work tommrow would i run that at form load? or in the event? edit did you mean CurrentCulture i dont see anything else close?

                                C Offline
                                C Offline
                                crash893
                                wrote on last edited by
                                #15

                                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Net.NetworkCredential("user","pw"); doesnt want to work Error Cannot implicitly convert type 'System.Net.NetworkCredential' to 'System.Globalization.CultureInfo'

                                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