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

Passing Esc to running file to close it in a BAT file?

25 views
Skip to first unread message

Peter Holmes

unread,
Nov 5, 2018, 1:09:20 PM11/5/18
to
Unhappily Win98 doesn't have built in scripting so I cannot use WshShell.Sendkeys
The BAT file would look like this with XP or later:

cd C:\PC30FG
Rem run configuration program with its config file...
start initfg.exe /pc30fg/initfg.cfg
Rem now close the program..
WshShell.Sendkeys "{ESC}"


Is there a DOS equivalent (or Freeware) program or command I can use?

Herbert Kleebauer

unread,
Nov 5, 2018, 4:39:08 PM11/5/18
to
On 05.11.2018 19:09, Peter Holmes wrote:
> Unhappily Win98 doesn't have built in scripting so I cannot use WshShell.Sendkeys
> The BAT file would look like this with XP or later:

Windows Script Host is part of Win98. But it often was
disabled because of security reasons.
(HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings)

Peter Holmes

unread,
Nov 6, 2018, 7:29:50 AM11/6/18
to
Thanks, Herbert but unfortunately there is no "Enabled" key in Settings. :~(
Only "default" an "Display Logo".

Herbert Kleebauer

unread,
Nov 6, 2018, 8:06:42 AM11/6/18
to
On 06.11.2018 13:29, Peter Holmes wrote:

>> > Unhappily Win98 doesn't have built in scripting so I cannot use WshShell.Sendkeys
>> > The BAT file would look like this with XP or later:
>>
>> Windows Script Host is part of Win98. But it often was
>> disabled because of security reasons.
>> (HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings)
>
> Thanks, Herbert but unfortunately there is no "Enabled" key in Settings. :~(
> Only "default" an "Display Logo".

As far as I remember, if you installed Win98, it was
optional to also install WSH. If you still have the
Win98 CD you can add WSH if it is not already installed.
Follow the instruction in the link to check if WSH
is installed:

http://www-personal.k-state.edu/~james/uninstall-vbs.html

Peter Holmes

unread,
Nov 6, 2018, 9:27:28 AM11/6/18
to
I didn't install Win98SE. It came from a customer.
I've done more digging but it's really a puzzle.
The Windows\System32 folder has only three files in it, plus driver folder.
Option not available in Windows Setup->Accessories to (un)install.
I cannot find WSH5.6 available any more on the web but I have found an unofficial 'upgrade' which does have it.

Other option is to install from CD but I don't have the experience to extract from a CAB file .. and which CAB file??

Herbert Kleebauer

unread,
Nov 6, 2018, 11:45:25 AM11/6/18
to
On 06.11.2018 15:27, Peter Holmes wrote:

> Option not available in Windows Setup->Accessories to (un)install.
> I cannot find WSH5.6 available any more on the web but I have found an unofficial 'upgrade' which does have it.
>
> Other option is to install from CD but I don't have the experience to extract from a CAB file .. and which CAB file??

It should be easier to install Internet Explorer.

from: https://en.wikipedia.org/wiki/Windows_Script_Host

|| Windows Script Host is distributed and installed by default on
|| Windows 98 and later versions of Windows. It is also installed
|| if Internet Explorer 5 (or a later version) is installed.

Peter Holmes

unread,
Nov 7, 2018, 12:47:20 PM11/7/18
to
Have apparently successfully installed Windows Script Host.
Now appears in Registry and is Enabled '1'
I can run wscript from command line and get a positive response.
However the batch file command WshShell.Sendkeys fails;

cd C:\PC30FG
Rem run configuration program with its config file..
initfg.exe /pc30fg/initfg.cfg
Rem which succeeds but needs Esc input to exit..

Rem now close the program..
WshShell.Sendkeys "{ESC}"
Rem this fails with message
Rem "Bad command or filename"

Herbert Kleebauer

unread,
Nov 7, 2018, 5:22:21 PM11/7/18
to
On 07.11.2018 18:47, Peter Holmes wrote:

> I can run wscript from command line and get a positive response.
> However the batch file command WshShell.Sendkeys fails;

https://groups.google.com/forum/#!original/alt.msdos.batch/ZRVvwu0FQ_0/XAkGFGcSbkkJ

Peter Holmes

unread,
Nov 8, 2018, 10:13:44 AM11/8/18
to
Thank you for that. However still doesn't do what I need.
I didn't explain well.
I need to be able to pass an ESC directly to the running program.
With WSH (or nircmd) it doesn't seem possible but thanks again for your suggestions.

Herbert Kleebauer

unread,
Nov 8, 2018, 10:54:06 AM11/8/18
to
On 08.11.2018 16:13, Peter Holmes wrote:

> Thank you for that. However still doesn't do what I need.
> I didn't explain well.
> I need to be able to pass an ESC directly to the running program.
> With WSH (or nircmd) it doesn't seem possible but thanks again for your suggestions.

You could try a stand alone program like

http://cpap.com.br/orlando/SendKeysMore.asp

| It’s also interesting to be called from the dialog box of Windows
| Run command, from Windows Shortcuts, and from scripts that haven’t
| SendKeys statement like command lines in Windows console (CMD batch
| file, DOS BAT).
|
| Features:
|
| - Can be defined a wait in seconds before to start the keystroke sending
|
| - Can be defined a wait in seconds to give up, if the target windows aren't found
|
| - The target window can be the active windows or one with defined title

Or ask in a batch forum (usenet is pretty dead these days)
0 new messages