To stop a script in Windows PowerShell, you need to hit Control+Break on the keyboard. This also applies to a VBA macro in Excel, Word, or other VBA enabled program. This is problematic as my current HP laptop doesn't have a break key. The right shift key has the word "pause" printed dimly on the upper left corner. On a normal keyboard, the Pause key has the word Break printed across the front, and Ctrl+Pause stops a script from running. But that doesn't work on the HP keyboard. No combination of Fn, Ctrl, Shift, or any other keys acts as break.
On Windows 7, you can bring up the On Screen Keyboard and use that. Click Start, and type OSK into the search programs and files box. Ctrl+Pause only works on this laptop if the numeric keypad is shown. Click the Options button to turn on the numeric keypad. Then hit Ctrl+Pause to activate Ctrl+Break. This will stop the currently running script.
However, even easier is to just use Ctrl+C! Actually, I did that without thinking, since Ctrl+C is the standard way to stop running actions under Linux and other *nix versions. To test it in PowerShell, type:
Start-Sleep 60
Then press Ctrl+C. Stopped! In a VBA macro, this doesn't work, so you'll have to use the On Screen Keyboard.
Greg Reddick is a noted speaker, author, and software engineer. This blog covers all aspects of programming, particularly for Windows, and other related topics.
2011-06-17
Stopping a Windows Powershell Script When You Don't Have a Break Key
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.