Discussion:
How-to send CTRL+Z command in PowerShell
(too old to reply)
PaoloS
2007-11-27 09:05:02 UTC
Permalink
Hi all,
Who knows, how-to send CTRL+Z in PowerShell script? I need to send CTRL+Z,
when i'm using serial port. i know only from 1 guy from here how-to send CRLF
(`r`n) but i need to know CTRL+Z.

If somebody knows how-to, i will be very happy.

Thanks. PaoloS
Marco Shaw [MVP]
2007-11-27 12:57:25 UTC
Permalink
Post by PaoloS
Hi all,
Who knows, how-to send CTRL+Z in PowerShell script? I need to send CTRL+Z,
when i'm using serial port. i know only from 1 guy from here how-to send CRLF
(`r`n) but i need to know CTRL+Z.
If somebody knows how-to, i will be very happy.
Thanks. PaoloS
Calling Wscript should work:
PSH>$wscript=new-object -com wscript.shell
PSH>$wscript.sendkeys("^Z+{ENTER}")

Will that do?

Marco
--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
Karl Prosser[MVP]
2007-11-27 18:06:27 UTC
Permalink
Post by Marco Shaw [MVP]
PSH>$wscript=new-object -com wscript.shell
PSH>$wscript.sendkeys("^Z+{ENTER}")
woah, overkill

Bruce Payette [MSFT]
2007-11-27 16:33:16 UTC
Permalink
Ctrl-Z is ASCII value 26 so you can insert this character into a string by
doing:

$stringWithCtrlZ = "Ctrl-Z is $([char] 26)"

-bruce
--
Bruce Payette [MSFT]
Principal Developer, Windows PowerShell
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.

Visit the Windows PowerShell Team blog at:
http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:
http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
My Book: http://manning.com/powershell
Post by PaoloS
Hi all,
Who knows, how-to send CTRL+Z in PowerShell script? I need to send CTRL+Z,
when i'm using serial port. i know only from 1 guy from here how-to send CRLF
(`r`n) but i need to know CTRL+Z.
If somebody knows how-to, i will be very happy.
Thanks. PaoloS
Loading...