Another rather specialised use case.....maybe!
What!
Using the PowerShell profile script to define aliases to start QAP, and to use QAPmessenger for launching the main menu and sub-menus.
Why?
There are several reason:
1:
When working with remote machines in a "windowed" RDP session the use of shortcuts/hotkeys, like the CTRL Double Tap, is a pain in the a.....
The shortcuts gets intercepted by the local host, so it is a total hit and miss exercise.
(Because I prefer the RDP setting "Apply Windows key combinations" to be "Only when using the full screen").
2:
The problem above gets very annoying when remoting to a Windows Server Core machine where the command line is king and the mouse is almost an optional extra.
3:
Avoid having several batch files polluting my servers, files that I have to maintain.... not gonna happen.
The PS profile
Every time you start PowerShell with "powershell" or "pwsh" a profile script runs in the background.
You can check the location and name of the script with this command:
Get-Variable -Name profile
Edit the PS profile
To edit (or create) the profile script type:
notepad $profile
Enter your commands and save the file.
The next time pwsh/powershell starts, the commands runs.
Example
This part of an actual profile script on one of my servers. Adjust it accordingly to fit your environment.
Code:
function qapstart {
Start-Process -FilePath C:\quickaccesspopup-$env:computername\QuickAccessPopup-64-bit.exe -WorkingDirectory "C:\quickaccesspopup-$env:computername"
}
function qapmainmenu {
Start-Process -FilePath C:\quickaccesspopup-$env:computername\QAPmessenger.exe -ArgumentList "ShowMenuLaunch" -WorkingDirectory "C:\quickaccesspopup-$env:computername"
}
function qapscripts {
Start-Process -FilePath C:\quickaccesspopup-$env:computername\QAPmessenger.exe -ArgumentList "ShowMenuLaunch","`"> ServerScripts`"" -WorkingDirectory "C:\quickaccesspopup-$env:computername"
}
Set-Alias -Name qap -Value qapstart
Set-Alias -Name qp -Value qapmainmenu
Set-Alias -Name qs -Value qapscripts
Clear-Host
Write-Host -ForegroundColor White -BackgroundColor DarkBlue "Alias definitions (local):"
Write-Host -ForegroundColor Red "qap: alias for starting QAP (one time, after a reboot)"
Write-Host -ForegroundColor Red "qp: alias for the QAP main menu"
Write-Host -ForegroundColor Red "qs: alias for the QAP ServerScripts menu"
That's it for now!
Regards,
joeNOR