Send Windows Key in batch script

Zinger picture Zinger · Aug 16, 2018 · Viewed 23.6k times · Source

I've recently been using the SendKeys function using Batch script.

I've understood how to input certain keys into a window, such as the tab key:

%SendKeys% "{TAB}"

Or the backspace key:

%SendKeys% "{BACKSPACE}"

But I have been trying to input the Windows key without pressing it.

Unfortunately, I do not know what the batch name for it is. I've tried:

WIN
WINDOWS
WINKEY
START
LWIN

But none have worked.

I've looked everywhere for this, and help would be greatly appreciated.

Answer

John Kens picture John Kens · Aug 16, 2018

There is currently no way to simulate the windows home logo in sendkey's, howevery this does not mean it's not possible.

If you take a look at the windows shortcut keys you will find you can simulate Open Start with the following key combinations: Ctrl + Esc.

To simulate this in batch, you can use: powershell -c "$wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{ESCAPE}') or in your case: %SendKeys% "^{ESCAPE}".

As stated in sendkeys:

  • "^" - Simulates a Ctrl key press.
  • "{ESCAPE}" - Simulates a Esc key press.