Add keyboard shortcuts in Windows PE
https://www.systanddeploy.com/2019/12/add-keyboard-shortcuts-in-windows-pe.html
In this post I will explain you, how to add shortcut key under Windows PE to run a specific program, for instance run an EXE using key F1 or after clicking on print screen.
Context
In a previous post I shared a tool I created that allows you to make screenshot under Windows PE, see the post here.
Now I want to be able to run this tool directly using a specific touch instead of open cmd prompt then navigating through the EXE path.
I want also to be able to open a PowerShell prompt directly using a key like F1 an regedit using F2.
How to add shortcut key ?
To do this, there is a great and free solution called AutoKey.
See below some ways to create your shortcut. In those examples we want to run regedit from Windows PE.
#r::Run regedit: this means the Win + r
F1::Run regedit: F1
F6::Run regedit: F6
!r::Run regedit: means Alt + r
^s::Run regedit: this means Ctrl + r
+r::Run regedit: this means Shift + r
^F6::Run regedit: Ctrl + F6
See here how to use it.
My Autokey file
For the test I want to run some programs using specific shortcut as below:
- Printscreen: Run my tool ScreenMe.exe
- F1: Run PowerShell
- F2: Run Regedit
How it works ?
1. Download the AutoKey EXE, here
2. Install it on your computer
3. Go to the documentation in order to see how to use hotkey part
4. Create a file WinPE_Keys.ahk
5. Edit the file using Notepad++ for instance
6. Add your touch hotkey, in my case this will be as below:
printscreen::Run ScreenMe
F1::Run powershell
F2::Run regedit
7. Save the file
8. Do a right click on the WinPE_Keys.ahk file then click on Compile Script
Integrate in boot image
In this part we will run our EXE through a cmd in the boot image and run it when WinPE starts using winpeshl.ini.
1. Create a file Run_keys.cmd
2. Edit it and add the below command:
powershell.exe -Command "Start-Process 'x:\windows\system32\winpe_keys.exe'"
3. Mount your boot image, in my case LiteTouchPE_x64.wim
2. Go to Windows\System32
3. Copy the WinPE_Keys.exe
4. Copy the file Run_keys.cmd
4. Open the file winpeshl.ini
5. Add the following line: %SYSTEMROOT%\System32\run_keys.cmd
6. See below my an overview of my file:
Enregistrer un commentaire