Windows 11 and WindX: switching window focus after NET USE

Started by Alain Stucki, July 09, 2023, 04:20:44 PM

Previous topic - Next topic

Alain Stucki

Hello
We are using WindX on our windows clients. We run some programs that can be as old as 40 years and have been written on MAI business basic. So in those days we used OPEN (7) "LP" and then Print (7)" bla bla bla" with printers directly attached to the computer using ESC-sequences for character-based printing.

When we made the move to PxPlus we wrote a little "choose your printer" program where you can choose a printer and then it does INVOKE WAIT "[lcl]net use lpt1: \\192.168.xxxx\printershare" so the LPT1 was re-directed by windows to the appropriate printer share. Then you can still print to LP and the data flow is redirected to the printer share.

We have multiple WindX windows open on a client so we can work in several of our programs the same time.  This runs great up until Windows 10. But when a client runs on Windows 11, after the NET USE command the focus of the window changes to another instance of WindX.

Imagine you have two WindX windows open and in the first one you do the NET USE to redirect LPT1 somewhere. Windows will quickly open a command line window, execute the NET USE command and close its window again. But on Windows 11 the focus is then set on the wrong WindX window. When you type on your keyboard, the input will be in the second WindX window. You have to Alt-TAB or take your mouse curser and click the first WindX window to continue. Which is very annoying. Especially as up until Windows 10 I didn't experience this behaviour on any client.

So I think this is not a PxPlus bug. It's rather based on some changes of Windows 11 so that when the command line window opens, Windows doesn't rememenber which window was active before that.

So I wonder if there is a way I can instruct PxPlus to do the NET USE command in an "invisible" command line window so that no command line window (looks like DOS window) is opened and therefore the focus stays on the active WindX window.

Or could this still be solved in an update of WindX?

Thanks already for your ideas.

Alain


Devon Austen

Try:

INVOKE HIDE WAIT "[lcl]net use lpt1: \\192.168.xxxx\printershare"

this should run it in a minimized window.

https://manual.pvxplus.com/?directives/invoke.htm
Principal Software Engineer for PVX Plus Technologies LTD.

Alain Stucki

Dear Mr. Austen

Thanks so much for your help. I tried it and YES.... it works!

I always thought the HIDE option would just minimize the window into the task bar, but now it does not appear at all. Fantastic.

Best regards
Alain Stucki

Alain Stucki

Dera Mr. Austen

Thanks again for your help. While studying the manual for the INVOKE directive again, I came across a section that I don't understand and cannot find any further information in the manual.

In the manual you write:
*************************************************
Example:

invoke env("COMSPEC")+" /K DIR C:\WINDOWS"

Note:
The env("COMSPEC") when running on Windows determines the correct command processor to be used. Some Windows commands (such as COPY and DIR) are built into command process and can be called using this type of statement.
*************************************************

I realise that using the env("COMSPEC") commands like COPY, DIR etc that are integrated into command.com will be used. But what does the /K do? I understand the DIR C:\WINDOWS command but why is there a /K before the DIR command? When I time this into a cmd-window I get an error. So it's not a windows specific command.

This time I really tried to find the answer in the manual but I could not find what /K does and if there are any other such options available.

Best regards
Alain

Devon Austen

the \K is an argument to the cmd.exe program

The COMSPEC environment variable resolves to something like "%SystemRoot%\system32\cmd.exe" the \K is an argument passed to it telling it to remain open after running the command that follows.

https://ss64.com/nt/cmd.html
Principal Software Engineer for PVX Plus Technologies LTD.

Alain Stucki

Thank you very much for your fast replies, support and help!