System.Diagnostics.Process.Start

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • programmerboy
    New Member
    • Jul 2007
    • 84

    System.Diagnostics.Process.Start

    I am trying to open folders on different servers using System.Diagnost ics.Process.Sta rt method. Some folders are opening but others are giving me error that unknown user name and password. Is there a way I can pass user id and password to this method so it can open folder for me. Lets say my user id is "abc123" and password is "password".
    Thanks in advance
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Check the ProcessStartInf o object, it appears to have places were credentials can be supplied.

    Comment

    • programmerboy
      New Member
      • Jul 2007
      • 84

      #3
      Originally posted by Plater
      Check the ProcessStartInf o object, it appears to have places were credentials can be supplied.
      I am not sure what you meant. If you could please give me an example then it will be nice.
      Thanks

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Originally posted by programmerboy
        I am not sure what you meant. If you could please give me an example then it will be nice.
        Thanks
        You should try to look things up for yourself as well. Did you even google it?

        It's not too hard:
        Code:
        using System.Diagnostics;
        .
        .
        .
        ProcessStartInfo psi = new ProcessStartInfo("path to executable here");
        psi.UserName = "username";
        string p = "password";
        char[] ch = p.ToCharArray();
        foreach(char c in ch)
          s.AppendChar(c);
        psi.Password = s;
        Process.Start(psi);
        You should learn to use IntelliSense. It's the popup in Visual Studio that suggests/autofinishes code for you. Type in an object and then a period, and it will show you its methods and members. I've learned more by scrolling through that popup than I have from anything else.

        For example, I'd never heard of a SecureString before I tried this. But using IntelliSensee, I figured it out without having to go to the internet. It's a good trick to know.

        Comment

        • programmerboy
          New Member
          • Jul 2007
          • 84

          #5
          Originally posted by insertAlias
          You should try to look things up for yourself as well. Did you even google it?

          It's not too hard:
          Code:
          using System.Diagnostics;
          .
          .
          .
          ProcessStartInfo psi = new ProcessStartInfo("path to executable here");
          psi.UserName = "username";
          string p = "password";
          char[] ch = p.ToCharArray();
          foreach(char c in ch)
            s.AppendChar(c);
          psi.Password = s;
          Process.Start(psi);
          You should learn to use IntelliSense. It's the popup in Visual Studio that suggests/autofinishes code for you. Type in an object and then a period, and it will show you its methods and members. I've learned more by scrolling through that popup than I have from anything else.

          For example, I'd never heard of a SecureString before I tried this. But using IntelliSensee, I figured it out without having to go to the internet. It's a good trick to know.
          Thanks man! I will definitely use your advice.

          Comment

          • Curtis Rutland
            Recognized Expert Specialist
            • Apr 2008
            • 3264

            #6
            Originally posted by programmerboy
            Thanks man! I will definitely use your advice.
            Oops, just so you know, I missed a piece of code there that you might need:
            [code]
            .
            .
            //just insert this line
            System.Security .SecureString s = new System.Security .SecureString() ;
            //above this line
            string p = "password";
            .
            .
            .

            Comment

            Working...