batch file does not work with shortcut key
Moderator: DosItHelp
batch file does not work with shortcut key
Using Windows 7 and wrote a little batch script to open an image file of interest in the native Windows Photo Viewer, so basically am just using the command:
CALL somepic.png
This works fine when I click on the program or it's shortcut or enter it at the commandline. However, it does not work when I try to execute the program by shortcut command key (e.g. Ctrl-Alt-V) created under the shortcut's properties.
I don't have a problem running other batch files this way. any help appreciated!
CALL somepic.png
This works fine when I click on the program or it's shortcut or enter it at the commandline. However, it does not work when I try to execute the program by shortcut command key (e.g. Ctrl-Alt-V) created under the shortcut's properties.
I don't have a problem running other batch files this way. any help appreciated!
Re: batch file does not work with shortcut key
Try another key combination - maybe there is a clash.
Use this too: I'm not sure how call works with it at all.
Use this too: I'm not sure how call works with it at all.
Code: Select all
start "" pic.png
Re: batch file does not work with shortcut key
Yes, it was a clash! When it first didn't work I suspected a clash and so tried a different lettter (m), unluckily that was also a letter that clashed...arrrrrrrgggghhhhhh...freaking windows!
Re: batch file does not work with shortcut key
That makes for an interesting question though. Is there a way to find all the shortcut keys assigned. I assume they all exist within the registry.
Re: batch file does not work with shortcut key
see:
which, ultimately, will lead you here:
http://www.tomshardware.co.uk/forum/19797-45-custom-shortcut-keys-list-remove#8344880
Which makes no sense at all (well... at least to me).
Why on earth would windows calculate them at logon?!
which, ultimately, will lead you here:
http://www.tomshardware.co.uk/forum/19797-45-custom-shortcut-keys-list-remove#8344880
Which makes no sense at all (well... at least to me).
Why on earth would windows calculate them at logon?!
Re: batch file does not work with shortcut key
AiroNG wrote:which, ultimately, will lead you here:
http://www.tomshardware.co.uk/forum/19797-45-custom-shortcut-keys-list-remove#8344880
Thanks for that link.
The solution on that page has issues and fails in later Windows, but I used the info to create a batch file that works to list the hotkeys.
Code: Select all
@echo off
(
echo set WshShell = WScript.CreateObject("WScript.Shell"^)
echo A = Wscript.Arguments(0^)
echo set lnk = WshShell.CreateShortcut(A^)
echo If lnk.hotkey ^<^> "" then wscript.echo lnk.hotkey ^& " - " ^& A
)>"%temp%\findhotkey.vbs"
for %%a in (
"%UserProfile%\desktop"
"%UserProfile%\Start Menu"
"%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu"
"%Public%\Desktop"
"%AllUsersProfile%\desktop"
"%AllUsersProfile%\Start Menu"
) do (
cd /d "%%~a" 2>nul && (for /r %%b in (*.lnk *.pif *.url) do cscript /nologo "%temp%\findhotkey.vbs" "%%b")
)
del "%temp%\findhotkey.vbs"
pause
Re: batch file does not work with shortcut key
foxi,
i used your code in my window-7 32-bit netbook:
result is:
incompatiable to my computer?
-----------------
thanks
bars
i used your code in my window-7 32-bit netbook:
result is:
Code: Select all
C:\Users\Jocelyn\AppData\Local\Temp\findhotkey.vbs(4, 1) Microsoft VBScript runtime error: Object doesn't support this property or method: 'lnk.hotkey'
C:\Users\Jocelyn\AppData\Local\Temp\findhotkey.vbs(4, 1) Microsoft VBScript runtime error: Object doesn't support this property or method: 'lnk.hotkey'
Press any key to continue . . .
incompatiable to my computer?
-----------------
thanks
bars
Re: batch file does not work with shortcut key
That's curious. The documentation which supports that .hotkey goes back to Win9x so it should work.
Can someone else test it please?
Can someone else test it please?
Re: batch file does not work with shortcut key
@foxidrive
Test on win7 (64bit). got the same error as bars143.
Test on winXP (32bit, virtual): works perfect.
Test on win7 (64bit). got the same error as bars143.
Test on winXP (32bit, virtual): works perfect.
Re: batch file does not work with shortcut key
Thanks for the tests.
Windows 7 (32 bit) works fine here but...
I've discovered two things - it doesn't support some types of file shortcuts - maybe they were created with a different or older shortcut creation method.
It does still work with the supported links, but each of those unsupported files returns an error like this:
c:\Temp\findhotkey.vbs(5, 1) Microsoft VBScript runtime error: Object doesn't support this property or method: 'lnk.hotkey'
Another error occurs in my XP VM and it seems that the *.pif should be removed in the FOR loop as this error is returned:
c:\Temp\findhotkey.vbs(3, 1) WshShell.CreateShortcut: The shortcut pathname must end with .lnk or .url.
Windows 7 (32 bit) works fine here but...
I've discovered two things - it doesn't support some types of file shortcuts - maybe they were created with a different or older shortcut creation method.
It does still work with the supported links, but each of those unsupported files returns an error like this:
c:\Temp\findhotkey.vbs(5, 1) Microsoft VBScript runtime error: Object doesn't support this property or method: 'lnk.hotkey'
Another error occurs in my XP VM and it seems that the *.pif should be removed in the FOR loop as this error is returned:
c:\Temp\findhotkey.vbs(3, 1) WshShell.CreateShortcut: The shortcut pathname must end with .lnk or .url.
Re: batch file does not work with shortcut key
Sadly, i have absolutely no experience with VBscript.
Because of that fact i tried a different approach:
I created some shortcuts (win7 .lnk) to a batch file and gave them different shortcut keys.
then i renamed and opened them with VBinDiff and found what i was looking for:
test1.txt (shortcut: ctrl + alt + i)
0000 0040: 49 06 00 00 00 00 00 00 00 00 00 00 E5 00 14 00 I....... ....Õ...
test2.txt (shortcut: ctrl + alt + p)
0000 0040: 50 06 00 00 00 00 00 00 00 00 00 00 E5 00 14 00 P....... ....Õ...
test3.txt (shortcut: ctrl + shift + p)
0000 0040: 50 03 00 00 00 00 00 00 00 00 00 00 E5 00 14 00 P....... ....Õ...
test4.txt (shortcut: shift + alt + p)
0000 0040: 50 05 00 00 00 00 00 00 00 00 00 00 E5 00 14 00 P....... ....Õ...
test5.txt (shortcut: ctrl + alt + shift + p)
0000 0040: 50 07 00 00 00 00 00 00 00 00 00 00 E5 00 14 00 P....... ....Õ...
IF all shortcut keys would be stored in this manner it could be possible to write a batch-script to search and list them.
To be honest, my knowledge of batch isn't good enough to test that
edit:
i posted my solution here: http://www.dostips.com/forum/viewtopic.php?f=3&t=5118
Because of that fact i tried a different approach:
I created some shortcuts (win7 .lnk) to a batch file and gave them different shortcut keys.
then i renamed and opened them with VBinDiff and found what i was looking for:
test1.txt (shortcut: ctrl + alt + i)
0000 0040: 49 06 00 00 00 00 00 00 00 00 00 00 E5 00 14 00 I....... ....Õ...
test2.txt (shortcut: ctrl + alt + p)
0000 0040: 50 06 00 00 00 00 00 00 00 00 00 00 E5 00 14 00 P....... ....Õ...
test3.txt (shortcut: ctrl + shift + p)
0000 0040: 50 03 00 00 00 00 00 00 00 00 00 00 E5 00 14 00 P....... ....Õ...
test4.txt (shortcut: shift + alt + p)
0000 0040: 50 05 00 00 00 00 00 00 00 00 00 00 E5 00 14 00 P....... ....Õ...
test5.txt (shortcut: ctrl + alt + shift + p)
0000 0040: 50 07 00 00 00 00 00 00 00 00 00 00 E5 00 14 00 P....... ....Õ...
IF all shortcut keys would be stored in this manner it could be possible to write a batch-script to search and list them.
To be honest, my knowledge of batch isn't good enough to test that
edit:
i posted my solution here: http://www.dostips.com/forum/viewtopic.php?f=3&t=5118