Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: creating a batch file to enter password in another program  (Read 42222 times)

0 Members and 1 Guest are viewing this topic.

Medaitor

    Topic Starter


    Rookie

    Thanked: 1
    creating a batch file to enter password in another program
    « on: March 07, 2010, 08:19:39 AM »
    How Can I create a batch file that will enter the password automatically into another program when it loads? 

    I was doing some research this morning and  haven't found what I"m looking for.   I use 2 programs on my office computer (this is my computer not the company I work for) every day that require me to enter my password everytime I load the programs. 

    Now I use Roboform form filler on the internet but that only fills forms on web based content in IE. 

    mat123



      Hopeful

      Thanked: 16
      • Yes
      • Yes
      • Yes
    • Experience: Familiar
    • OS: Windows XP
    Re: creating a batch file to enter password in another program
    « Reply #1 on: March 07, 2010, 04:52:41 PM »
    use this
    set wshshell = wscript.CreateObject("wscript.shell")
    wshshell.AppActivate "program"
    WshShell.SendKeys "password"
    save as .vbs



    Medaitor

      Topic Starter


      Rookie

      Thanked: 1
      Re: creating a batch file to enter password in another program
      « Reply #2 on: March 08, 2010, 07:17:14 AM »
      use this
      set wshshell = wscript.CreateObject("wscript.shell")
      wshshell.AppActivate "program"
      WshShell.SendKeys "password"
      save as .vbs


      Thanks a million!   Okay so I got this to work using one of the programs so far but it's entering the password in the "User ID:" field.  What do I need to add to the code to have it enter into the field labeled "Password:" .......  Or better yet have both of them entered.  Here's what my script code looks like (keep in mind that the window active is labeled "User Login" so I had to use that as the program name):

      set wshshell = wscript.CreateObject("wscript.shell")
      wshshell.AppActivate "User Login"
      WshShell.SendKeys "mypassword"

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: creating a batch file to enter password in another program
      « Reply #3 on: March 08, 2010, 07:23:47 AM »
      Quote
      set wshshell = wscript.CreateObject("wscript.shell")
      wshshell.AppActivate "User Login"
      WshShell.SendKeys "{tab}mypassword"

      this assumes you can press tab once to get from the userID to the password field. Also, if the userID is not filled in by default you should use "userID{tab}password{enter}"

      - I cannot remember if it was {enter} or {return}, but one of those should automate the press of the OK button.
      I was trying to dereference Null Pointers before it was cool.

      Medaitor

        Topic Starter


        Rookie

        Thanked: 1
        Re: creating a batch file to enter password in another program
        « Reply #4 on: March 08, 2010, 08:45:30 AM »
        BC - thanks the {tab} did the trick because the username was already there. 

        Medaitor

          Topic Starter


          Rookie

          Thanked: 1
          Re: creating a batch file to enter password in another program
          « Reply #5 on: March 08, 2010, 05:13:43 PM »
          One more question.... okay maybe it's not just one more question :-)

          I'm running this script for 2 separate programs so I have to keep 2 icons on my desktop amongst many others I use hotkeys for.  I'm tyring to minimize the amount of icons I have on my desktop so Is there a way to have the 2 scripts run in the same .vbs file?  I tried this but it enter the 2 different passwords together in one of the programs.  I thought maybe with an "if, then, else" statement or something coded in it would work the way I need it to.  I just don't understand this the VB language so.....

          Thanks in advance. 

          mat123



            Hopeful

            Thanked: 16
            • Yes
            • Yes
            • Yes
          • Experience: Familiar
          • OS: Windows XP
          Re: creating a batch file to enter password in another program
          « Reply #6 on: March 08, 2010, 06:13:20 PM »
           the appactive part needs to be in between the to passwords ;)



          Medaitor

            Topic Starter


            Rookie

            Thanked: 1
            Re: creating a batch file to enter password in another program
            « Reply #7 on: March 08, 2010, 07:09:56 PM »
            So it would look like this then?

            set wshshell = wscript.CreateObject("wscript.shell")
            wshshell.AppActivate "program#1"
            WshShell.SendKeys "password#1"
            wshshell.AppActivate "program#2"
            WshShell.SendKeys "password#2"

            I tried that and it still enters both passwords on top of each other in the program#1 but works on Program#2.  I'm sure I just have something wrong in the code. 

            mat123



              Hopeful

              Thanked: 16
              • Yes
              • Yes
              • Yes
            • Experience: Familiar
            • OS: Windows XP
            Re: creating a batch file to enter password in another program
            « Reply #8 on: March 08, 2010, 09:13:28 PM »
            better way put the two vbs files in a folder ex. C:\ex
            make a bat file same folder with this code
            Code: [Select]
            start 1.vbs
            start 2.vbs
            exit



            Medaitor

              Topic Starter


              Rookie

              Thanked: 1
              Re: creating a batch file to enter password in another program
              « Reply #9 on: March 09, 2010, 08:32:14 AM »
              better way put the two vbs files in a folder ex. C:\ex
              make a bat file same folder with this code
              Code: [Select]
              start 1.vbs
              start 2.vbs
              exit

              Okay I didn't think about that.  I can create the bat - convert to .exe and create a short cut with a hot key and voila.  Thanks. 

              mat123



                Hopeful

                Thanked: 16
                • Yes
                • Yes
                • Yes
              • Experience: Familiar
              • OS: Windows XP
              Re: creating a batch file to enter password in another program
              « Reply #10 on: March 09, 2010, 08:58:53 PM »
              your welcome



              cstambaugh



                Newbie

                • Experience: Beginner
                • OS: Unknown
                Re: creating a batch file to enter password in another program
                « Reply #11 on: July 23, 2012, 06:56:41 PM »
                Ok I am attempting this and having some issues... could you please assist me?

                set wshshell = wscript.CreateObject("wscript.shell")
                wshshell.AppActivate "path to .exe file"
                WshShell.SendKeys "Username here{tab}password here{enter}"
                This is what I have and have saved it as a .VB. it does not open the correct app, or anything.... What am I missing here???

                BC_Programmer


                  Mastermind
                • Typing is no substitute for thinking.
                • Thanked: 1140
                  • Yes
                  • Yes
                  • BC-Programming.com
                • Certifications: List
                • Computer: Specs
                • Experience: Beginner
                • OS: Windows 11
                Re: creating a batch file to enter password in another program
                « Reply #12 on: July 24, 2012, 06:53:24 PM »
                VBScript files have to be .vbs, not .vb.

                AppActivate activates an already running program by the title of it's window. If you want to start a program, There is something else to do it (I don't know what, specifically, possibly WScript.Exec()... (Not On windows at the moment, so I cannot check)

                I was trying to dereference Null Pointers before it was cool.

                cstambaugh



                  Newbie

                  • Experience: Beginner
                  • OS: Unknown
                  Re: creating a batch file to enter password in another program
                  « Reply #13 on: July 25, 2012, 04:14:16 PM »
                  Ok I will keep searching...