Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Script pauses when you click in the powershell text window

936 views
Skip to first unread message

Kris

unread,
Dec 7, 2007, 9:12:09 AM12/7/07
to
Suppose you have following code:
for ($i=0 ; $i -lt 10; $i++) { write-host $i ; start-sleep -s 1 }

Now, while the script is running, simply click with the mouse cursor
somewhere in the powershell's text window. The script will pause and
only continues when you press Enter. It turns out that clicking in the
text area actually invokes the text selection action for clipboard copy
operations.

This is all fine, but initially I got reports from people running my
script that my script paused for no reason at all. Eventually, it turned
out that the pause was caused by mouse clicks in the text window (often
caused when they simply wanted to give focus to the partially hidden
powershell window, after which they left and the script remained paused
until they returned hours later only to come to the conclusion that
nothing had happened in the mean time).

This easy copy-text feature is nice, but I was wondering if there is a
way to disable this (script-wise) so that people aren't able anymore to
accidentally pause the script. Being able to disable this feature would
make my my script more fool-proof.

Thanks,

Kris

Bob Landau

unread,
Dec 7, 2007, 11:21:00 AM12/7/07
to
Kris

The only method I know of changing this is in the registry

HKCU\Console\QuickEdit 0x1 (on) 0x0 (off)

Most of these settings unfortunately aren't reloaded when changed manually.
The user will need to log off.

The Command Console of course has a "special" relationship with it's
properties and does this on the fly if you change it via the menu.

Perhaps someone else will have better news

bob

Marco Shaw [MVP]

unread,
Dec 7, 2007, 11:28:19 AM12/7/07
to

> This easy copy-text feature is nice, but I was wondering if there is a
> way to disable this (script-wise) so that people aren't able anymore to
> accidentally pause the script. Being able to disable this feature would
> make my my script more fool-proof.

From what I can tell so far, running something in the background is not
affected:
http://jtruher.spaces.live.com/blog/cns!7143DA6E51A2628D!130.entry

Marco

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

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

Blog:
http://marcoshaw.blogspot.com

/\/\o\/\/ [MVP]

unread,
Dec 7, 2007, 2:16:00 PM12/7/07
to
This is "Feature" of the console itself, and does also happen when you use
CMD.EXE

Greetings /\/\o\/\/

Frank

unread,
Dec 8, 2007, 10:53:02 AM12/8/07
to
Would this be suggesting using cmd.exe to execute Powershell scripts to
alleviate the pausing?

Keith Hill [MVP]

unread,
Dec 8, 2007, 10:10:20 PM12/8/07
to
"Frank" <Fr...@discussions.microsoft.com> wrote in message
news:E8198C7A-D4D6-4EDE...@microsoft.com...

> Would this be suggesting using cmd.exe to execute Powershell scripts to
> alleviate the pausing?

Nope. MoW is just stating that CMD.exe has the same problem. Can you try
to opening the console Window properties and disabling Quick Edit and see if
that makes the problem go away? If so, you should be able to hack the
registry to temporarily disable "quick edit" in the current console and
re-enable it before exiting.

--
Keith

Oisin Grehan

unread,
Dec 8, 2007, 11:18:24 PM12/8/07
to
On Dec 8, 10:10 pm, "Keith Hill [MVP]"

Not entirely relevant but IIRC, quickedit was newly enabled by default
for windows 2000 (or was it NT4?), then removed again for XP. I
vaguely remember that nugget of console trivia, but I could be wrong.

- Oisin

Kris

unread,
Dec 10, 2007, 4:24:21 AM12/10/07
to
Keith Hill [MVP] wrote:
> Nope. MoW is just stating that CMD.exe has the same problem. Can you
> try to opening the console Window properties and disabling Quick Edit
> and see if that makes the problem go away?

Yes. Turning Quick Edit off makes the problem go away.

Thanks.

Marco Shaw [MVP]

unread,
Dec 10, 2007, 7:43:41 AM12/10/07
to

So at least you can go with what Bob says maybe about the registry edit,
then the *next* time, and forever after, the problem will be gone.

Marco

Kris

unread,
Dec 13, 2007, 5:22:41 AM12/13/07
to
Bob Landau wrote:
> HKCU\Console\QuickEdit 0x1 (on) 0x0 (off)

Marco Shaw [MVP] wrote:
> So at least you can go with what Bob says maybe about the registry edit,
> then the *next* time, and forever after, the problem will be gone.

I'm not sure this will work reliably. Currently I have QuickEdit still
enabled in my PowerShell session even though the registry value is set
to 0. Even after log-off or reboot, registry value is zero, but QE is
still enabled.

I've noticed that when I change the window's properties such as the QE
setting, you will be asked if you want to modify the shortcut that
started the session. So, I'm thinking that the registry value is a
global default value, which is easily overruled when the user has
applied the new properties to the shortcut.

Kris

0 new messages