Auto-PID execution for RDP files.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
RDC
Posts: 112
Joined: 29 Jan 2023, 10:22

Auto-PID execution for RDP files.

Post by RDC » 31 Jan 2023, 10:41

Hopefully I can express this correctly...
For my WFH laptop I have 3 separate .rdp files I have to load up every morning.
From my Google attempts I have found I can use Task Scheduler to do this, but near as I can tell it would only start one .rdp file using mstsc.exe found in the System32 folder.
So my question is.. can I have 3 separate .rdp files that I need to load on start up using the same password on all 3, using the PID I located for each using Window Spy.
From each of the 3 .rdp files they are Process 1, Process 2, and Process 3 using...

Process 1:
ahk_exe CredentialUIBroker.exe
ahk_pid 4724

Process 2:
ahk_exe CredentialUIBroker.exe
ahk_pid 6540

Process 3:
ahk_exe CredentialUIBroker.exe
ahk_pid 19412

...respectively. Any ideas or suggestions on how to even start something like this for a noob would be greatly appreciated... if it's even possible.
Many Many Thanks in advance!!

User avatar
DuckingQuack
Posts: 219
Joined: 20 Jan 2023, 18:20

Re: Auto-PID execution for RDP files.

Post by DuckingQuack » 02 Feb 2023, 22:04

Hey!
Alright, first things first: one script to launch three programs? Yes! Use PID's to launch them? Sorry, those aren't static values; they're assigned fresh upon each launch of the program, but we'll still need them, so were going to call for them when the programs are launched.

Now that's out of the way, we need to answer a few questions...
  • Do you have admin rights on this laptop? (Certain directories could be locked and prevent us from getting your script up and running, so it's best to check if you have full access to the needed directories which are the ones your executables are in.)
  • Are you cleared to put scripting programs on the work laptop? (*I* don't care, but this isn't really an activity worthy of being fired over.)
  • Do you know the full path to the executables you are wanting to start automatically? (I'm including a bonus script in case you don't!)
  • Are the executables actually all named the same? (We'll find out when we run the bonus script!)


Now for the meat and potatoes of this post... the template for you to create your personal run and login script!

Code: Select all

#Requires AutoHotkey v2.0
;TEMPLATE
;Place this script in your "Start Up" folder so it is started when you turn on the laptop

Run("D:\THIS\IS\THE\EXACT\PATH\CredentialUIBroker.exe",, "Max", &PID1)
WinWait "ahk_pid " PID1
Send(DO FIRST LOGIN STUFF)
;if the previous window interferes with the next window use WinMinimize

Run("D:\THIS\IS\THE\EXACT\PATH\CredentialUIBroker.exe",, "Max", &PID2)
WinWait "ahk_pid " PID2
Send(DO SECOND LOGIN STUFF)
;if the previous window interferes with the next window use WinMinimize

Run("D:\THIS\IS\THE\EXACT\PATH\CredentialUIBroker.exe",, "Max", &PID3)
WinWait "ahk_pid " PID3
Send(DO THIRD LOGIN STUFF)
ExitApp ;after everthing is done it will end itself


And for my next trick, I present to you, the bonus script!

Code: Select all

#Requires AutoHotkey v2.0
Esc:: ExitApp
;Run the program that you need to know the file path of and with it as the active window, press F11
;You'll get a small pop-up edit box that will let you copy and paste the path info
F11::{
    WinPID := WinGetPID("A")
    WinPath := ProcessGetPath(WinPID)
    TxtGui := Gui("AlwaysOnTop -Caption ToolWindow", "TxtGui")
    TxtGui.Add("Edit", "vEdit1", WinPath)
    TxtGui.Show("NoActivate")
}
I look forward to your great success!
Best of Luck,
The Duck

User avatar
DuckingQuack
Posts: 219
Joined: 20 Jan 2023, 18:20

Re: Auto-PID execution for RDP files.

Post by DuckingQuack » 07 Feb 2023, 18:30

@RDC any updates?
Also wanted to mention that the only parts to modify on the template is the file path and the series of send commands that performs the login. Anywhere that says PID needs to stay because it’s calling the pid variable.
Best of Luck,
The Duck

User avatar
RDC
Posts: 112
Joined: 29 Jan 2023, 10:22

Re: Auto-PID execution for RDP files.

Post by RDC » 12 Feb 2023, 19:20

Many thanks Duck!!
Code looks awesome. I will have to give it a try. I ended up just making a script so I just hit a par of keys and it inputs my password, toggles through the buttons and logs me on and into the tools. Figured since I have to use my PW so often anyhow it made the most sense.

Post Reply

Return to “Ask for Help (v1)”