Cannot get shortcut keys working on batch files

  • Thread starter Thread starter Terry Pinnell
  • Start date Start date
T

Terry Pinnell

On this XP Pro (SP2) PC I cannot get any shortcut keys to work on the
shortcuts made from any batch file.

For example, Test-01.bat contains this

@echo off
pause

I assigned it the shortcut <Ctl+Alt+3> (or any keys) as shown here

http://dl.dropbox.com/u/4019461/BatchProblem.jpg

But it doesn't run when I use the keys.

It runs fine if I d-click either the original batch file or its shortcut.

No difference after a reboot.

I installed a little program called Shortcut Key Explorer v1 01 by RJL
Software from http://www.rjlsoftware.com/software/utility/shortcutkeys/
which lists all the keyboard shortcuts in use. It found the couple I've
successfully installed, such as a test with Calculator. But for the test
batch file, even though it's shown as having ctl-alt-3 assigned in
the Properties, the Shortcutkeys list doesn't include it.

Very frustrating!

Anyone have any ideas please?
 
Terry Pinnell said:
On this XP Pro (SP2) PC I cannot get any shortcut keys to work on the
shortcuts made from any batch file.

For example, Test-01.bat contains this

@echo off
pause

I assigned it the shortcut <Ctl+Alt+3> (or any keys) as shown here

http://dl.dropbox.com/u/4019461/BatchProblem.jpg

But it doesn't run when I use the keys.

It runs fine if I d-click either the original batch file or its shortcut.

No difference after a reboot.

I installed a little program called Shortcut Key Explorer v1 01 by RJL
Software from http://www.rjlsoftware.com/software/utility/shortcutkeys/
which lists all the keyboard shortcuts in use. It found the couple I've
successfully installed, such as a test with Calculator. But for the test
batch file, even though it's shown as having ctl-alt-3 assigned in
the Properties, the Shortcutkeys list doesn't include it.

Very frustrating!

Anyone have any ideas please?

Perhaps you need to invoke your batch file like so in the shortcut:
cmd /c "c:\Tools\MyBatchfile.bat

About the list of current shortcuts: Try the following.
1. Copy and paste the code below into c:\Windows\ShortcutKeys.vbs
2. Double-click it. It will scan each and every shortcut you have and report
if there is a shortcut key combination.
3. Report the result.

aKeys = Split("Ctrl+Shift,"",Alt+Shift,Alt+Ctrl", ",")
Set oWshShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sList = "\Links.txt"
sProfiles = oWshShell.ExpandEnvironmentStrings("%UserProfile%\..")
sTemp = oWshShell.ExpandEnvironmentStrings("%Temp%")
oWshShell.Run "cmd.exe /u /c dir /s /a /b """ & sProfiles & "\*.lnk"" > """
_
& sTemp & sList & "", 0, True 'Use Unicode for non-ASCII file names

Set oList = oFSO.OpenTextFile(sTemp & sList, 1, False, -1) 'Read the names
in Unicode format
aLinks = Split(oList.ReadAll, VbCrLf)
oList.Close
oFSO.DeleteFile (sTemp & sList)

iCount = 0
For Each sName In (aLinks)
If sName <> "" Then
iCount = iCount + 1
sString = oFSO.OpenTextFile(sName).Read(70)
cKey = Mid(sString, 66, 1) 'The bytes are read in reverse order . . .
Letter = Mid(sString, 65, 1)
If cKey <> Chr(0) Then MsgBox aKeys(Asc(cKey)-3) & "+" & Letter & " " &
sName, vbOK, "Link file keyboard shortcuts"
End If
Next
 
Terry said:
On this XP Pro (SP2) PC I cannot get any shortcut keys to work on the
shortcuts made from any batch file.

For example, Test-01.bat contains this

@echo off
pause

I assigned it the shortcut <Ctl+Alt+3> (or any keys) as shown here

http://dl.dropbox.com/u/4019461/BatchProblem.jpg

But it doesn't run when I use the keys.

It runs fine if I d-click either the original batch file or its
shortcut.

No difference after a reboot.

I installed a little program called Shortcut Key Explorer v1 01 by RJL
Software from
http://www.rjlsoftware.com/software/utility/shortcutkeys/ which lists
all the keyboard shortcuts in use. It found the couple I've
successfully installed, such as a test with Calculator. But for the
test batch file, even though it's shown as having ctl-alt-3 assigned
in
the Properties, the Shortcutkeys list doesn't include it.

Very frustrating!

Anyone have any ideas please?

Don't know about your specific problem but normally shortcuts being invoked
via a keyboard combo have to be in either the desktop or Start/Programs. Try
moving the shortcut to one of those.

--

dadiOH
____________________________

dadiOH's dandies v3.06...
....a help file of info about MP3s, recording from
LP/cassette and tips & tricks on this and that.
Get it at http://mysite.verizon.net/xico
 
Pegasus said:
Perhaps you need to invoke your batch file like so in the shortcut:
cmd /c "c:\Tools\MyBatchfile.bat

Thanks Pegasus, but that still didn't fix it. See also my reply to dadiOH.
About the list of current shortcuts: Try the following.
1. Copy and paste the code below into c:\Windows\ShortcutKeys.vbs
2. Double-click it. It will scan each and every shortcut you have and report
if there is a shortcut key combination.
3. Report the result.

aKeys = Split("Ctrl+Shift,"",Alt+Shift,Alt+Ctrl", ",")
Set oWshShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sList = "\Links.txt"
sProfiles = oWshShell.ExpandEnvironmentStrings("%UserProfile%\..")
sTemp = oWshShell.ExpandEnvironmentStrings("%Temp%")
oWshShell.Run "cmd.exe /u /c dir /s /a /b """ & sProfiles & "\*.lnk"" > """
_
& sTemp & sList & "", 0, True 'Use Unicode for non-ASCII file names

Set oList = oFSO.OpenTextFile(sTemp & sList, 1, False, -1) 'Read the names
in Unicode format
aLinks = Split(oList.ReadAll, VbCrLf)
oList.Close
oFSO.DeleteFile (sTemp & sList)

iCount = 0
For Each sName In (aLinks)
If sName <> "" Then
iCount = iCount + 1
sString = oFSO.OpenTextFile(sName).Read(70)
cKey = Mid(sString, 66, 1) 'The bytes are read in reverse order . . .
Letter = Mid(sString, 65, 1)
If cKey <> Chr(0) Then MsgBox aKeys(Asc(cKey)-3) & "+" & Letter & " " &
sName, vbOK, "Link file keyboard shortcuts"
End If
Next

Running it gave me an error message titled Windows Script Host:

Script: C:\WINDOWS\ShortcutKeys.vbs
Line: 9
Char: 3
Error: Expected statement
Code: 800A0400
Source: Microsoft VBScript compilation error

Running the utility I mentioned (of the same name) seems to do the job of
identifying valid (i.e. working) keyboard shortcuts however.
 
dadiOH said:
Don't know about your specific problem but normally shortcuts being invoked
via a keyboard combo have to be in either the desktop or Start/Programs. Try
moving the shortcut to one of those.

Thanks dadiOH, that's a breakthrough.

I was using a simple batch file for testing:

Test-01.bat
-----------
@echo off
pause

But it would not run from a keyboard shortcut. After moving the shortcuts
from C:\Batch to C:\Documents and Settings\All Users\Start
Menu\Programs\Batch as you suggested, it now does - EVENTUALLY.

It is taking some 20 seconds to run any shortcut with a keyboard shortcut!
This applies to ALL the shortcuts I've tried, not just those to batch files.
For example, shortcuts to Notepad, Calculator, etc. Yet all run immediately
if I d-click the shortcut instead of using the keyboard.

Any idea what on earth can be happening to take 20 seconds or so?!

I'll reboot after posting this to see if that makes any difference.
 
Thanks dadiOH, that's a breakthrough.

I was using a simple batch file for testing:

Test-01.bat
-----------
@echo off
pause

But it would not run from a keyboard shortcut. After moving the shortcuts
from C:\Batch to C:\Documents and Settings\All Users\Start
Menu\Programs\Batch as you suggested, it now does - EVENTUALLY.

It is taking some 20 seconds to run any shortcut with a keyboard shortcut!
This applies to ALL the shortcuts I've tried, not just those to batch files.
For example, shortcuts to Notepad, Calculator, etc. Yet all run immediately
if I d-click the shortcut instead of using the keyboard.

Any idea what on earth can be happening to take 20 seconds or so?!

I'll reboot after posting this to see if that makes any difference.

Rebooting didn't solve it.

Another odd thing is that if I try again some 10 minutes later, say with the
Notepad shortcut activated by ctl-alt-5, the first attempt brings up the
program immediately. All subsequent attempts take 20 secs or so, until after
another long wait when I get just the single correct result again.

Weird ...
 
Terry Pinnell said:
Thanks Pegasus, but that still didn't fix it. See also my reply to dadiOH.


Running it gave me an error message titled Windows Script Host:

Script: C:\WINDOWS\ShortcutKeys.vbs
Line: 9
Char: 3
Error: Expected statement
Code: 800A0400
Source: Microsoft VBScript compilation error

Running the utility I mentioned (of the same name) seems to do the job of
identifying valid (i.e. working) keyboard shortcuts however.

Glad you got it (partly) resolved. It is now a moot point but the error you
mention happened because your news reader split a long line into two
separate lines. Can't do this! The following code must be placed on one
single line:

If cKey <> Chr(0) Then MsgBox aKeys(Asc(cKey)-3) & "+" & Letter & " " &
sName, vbOK, "Link file keyboard shortcuts"
 
Terry said:
Thanks dadiOH, that's a breakthrough.

I was using a simple batch file for testing:

Test-01.bat
-----------
@echo off
pause

But it would not run from a keyboard shortcut. After moving the
shortcuts from C:\Batch to C:\Documents and Settings\All Users\Start
Menu\Programs\Batch as you suggested, it now does - EVENTUALLY.

It is taking some 20 seconds to run any shortcut with a keyboard
shortcut! This applies to ALL the shortcuts I've tried, not just
those to batch files. For example, shortcuts to Notepad, Calculator,
etc. Yet all run immediately if I d-click the shortcut instead of
using the keyboard.

Any idea what on earth can be happening to take 20 seconds or so?!

Nope but if you like KB shortcuts go get this. I've used it for years, easy
to use, never any problems.
http://www.brianapps.net/hotkeyplus/

Or here, the home page isn't working, don't know if that is temporary or
not.
http://www.softpedia.com/get/System/Launchers-Shutdown-Tools/Hot-Key-Plus.shtml

--

dadiOH
____________________________

dadiOH's dandies v3.06...
....a help file of info about MP3s, recording from
LP/cassette and tips & tricks on this and that.
Get it at http://mysite.verizon.net/xico
 
dadiOH said:
Nope but if you like KB shortcuts go get this. I've used it for years, easy
to use, never any problems.
http://www.brianapps.net/hotkeyplus/

Or here, the home page isn't working, don't know if that is temporary or
not.
http://www.softpedia.com/get/System/Launchers-Shutdown-Tools/Hot-Key-Plus.shtml

Thanks. However, I already have a couple of programs (Macro Express Pro and
my trusty old Stiletto power utility) which let me do that. I currently have
several hundred KB shortcuts assigned.

This particular requirement for a KB shortcut to a shortcut to a batch file
was because I occasionally get a 'runaway situation' when writing/testing
Macro Express macros. None of its documented STOP methods work in that
extreme situation. So chaos can sometimes rule for a while. I even have
trouble getting to XP Pro TM with Ctl-Alt-Del. So, after help in the
alt.msdos.batch.nt newsgroup I wrote a one-line batch file, ME-Kill.bat:

TASKKILL /F /IM MacExp.exe /IM MacEdit.exe /IM MacScript.exe

which stops the three processes making up Macro Express.

I wasn't particularly hopeful that it would work (because KB operation is so
disrupted), but thought I'd try it next time if Ctl-Alt-Del didn't work,
before hitting the Reset or Power-Off buttons. But obviously, this issue with
a possible 20 second delay is a show-stopper on that idea!

Meanwhile I assigned it to Ctl+Alt+k as a Stiletto KB shortcut to
ME-Kill.bat.

But I had a runaway last night giving me an opportunity to try it. It failed!

Eventually, I got TM up. So I'm guessing that, if *anything* will work in
those runaway states, Ctl+Alt+Del will - although it might take 30 secs or
more.
 
Billns said:
I think that may be the root of your problem delays. How can you
remember all those shortcuts?

Bill

Shortcut to a text file that lists them? :)

--

dadiOH
____________________________

dadiOH's dandies v3.06...
....a help file of info about MP3s, recording from
LP/cassette and tips & tricks on this and that.
Get it at http://mysite.verizon.net/xico
 
Todd Vargo said:
Or better yet, I would store them as links in an HTML file.

I've memorised a small a minority, for 'global' use, but most are grouped by
application. So when I'm working on say video editing I fairly quickly
re-familiarise myself with those. Same for map work, macro-writing, graphics,
email, etc.

Even so, yes, it's a challenge. So I'm gradually transferring to menus
instead. Middle-clicking a major application's title bar brings up a menu,
like this example for Google Earth.
http://dl.dropbox.com/u/4019461/GE-Menu.jpg

Note that for many of the menu entries I include a note of their shortcut in
their names. So <Alt+Ctrl+o> will 'Open Navigation Options'. If I repeat that
frequently in a session, then I use that KB shortcut, rather than the menu.
 
Back
Top