2
0
At my company we have small workstations ~13 inch with touchscreen.
The operating system is: Microsoft Windows Embedded Standard 6.1.7601 Service Pack 1 Build 7601
The workstations have 5 buttons on them that can be mapped for any key combination. (example ctrl+alt+shift+[any key on the keyboard]
)
There are two programs that must run on them in order for the workers to be able to work. Sometimes the workers accidentally close one of the programs, so I have decided to get a solution to this, since they can not start the programs by themselves.
So I have:
- created a batch file, that when started, it checks if the programs are running, if not, it starts them;
- created a shortcut of the batch file (in %appdata%\Microsoft\Windows\Start Menu\Programs
as suggested here);
- added a shortcut key (ctrl + alt + s);
- assigned one of the buttons on the workstation to the key binding.
It seemed a good idea in theory but in practice the shortcut key binding wasn't working properly.
After troubleshooting, I realized that one of the programs is causing the problem.
Lets call the programs A
and B
. When B
or the desktop is in front, the key combination works properly and launches the batch file. A
works in full screen. So when the key combination is pressed while A
is in front it doesn't work.
So I have assigned an alt + tab
key combination for another button but this is where the problem kicks in.
If I have previously pressed the ctrl + alt + S
key combination while A
was in front, it wont work afterwards even after I switched to B
or to the desktop.
What makes it more interesting is, that if I create another shortcut key on another shortcut file, lets say ctrl + alt + D
and run it after ctrl + alt + S
stopped working, it fixes it and the ctrl + alt + S
starts working again while B
or the desktop has focus.
Tried this, didn't work.
Red this forum. No solution.
I am looking for a solution/workaround/another method to solve this problem.
I don't want to install any third party programs. I can however modify settings and the registry if needed.
EDIT:
The batch file
echo off
tasklist /FI "IMAGENAME eq progB.exe" 2>NUL | find /I /N "progB.exe">NUL
if "%ERRORLEVEL%"=="1" (
cd C:\<progB path>
start /MAX progB.exe
)
tasklist /FI "IMAGENAME eq progA.exe" 2>NUL | find /I /N "progA.exe">NUL
if "%ERRORLEVEL%"=="1" C:\<progA path>
exit
1Shortcut keys were always flaky. A brute-force solution would be to schedule the execution of the batch file repetitively every minute. If the programs are running, I don't suppose that this will be noticeable by the user. – harrymc – 2016-02-12T19:49:32.407
@harrymc - I was thinking of something similar, but it might cause problems if the worker is scanning and the program looses focus. Also the workstations work a bit slow and even for a simple batch file like this it takes 5-10 seconds to run – Divin3 – 2016-02-15T06:30:02.190
5-10 seconds just to detect that the programs are running? If you publish the batch file we might be able to improve it. – harrymc – 2016-02-15T06:42:58.043
@harrymc - updated. It takes long because the workstations are too slow – Divin3 – 2016-02-15T07:13:29.347
I don't know what you have on these systems. WMIC might be faster :
WMIC process get Caption | find /i /n "prog.exe
. There is also Powershell Get-Process and also Powershell via WMI: Get-WMIObject Win32_Process. – harrymc – 2016-02-15T08:39:39.107@harrymc - the stations have Intel atom processors @ 1.6 Ghz, 2Gb ram, 32 GB SSD. The processor is just enough to run the necessary programs. Even opening an explorer window sometimes seems like an eternity on these systems. Checked WMIC, it is a much more elegant solution but seems to have the same speed or even slower – Divin3 – 2016-02-15T08:53:49.303
Questions: (1) Are progA/B modifiable par yourself? (2) Can you introduce new programs? (3) If not, is it for security reasons and is a new program compiled by yourself acceptable? (4) If you open cmd and do "dir /path/to//file" is the dir also slow? – harrymc – 2016-02-15T09:31:12.953
@harrymc - 1. both programs have an ini file that can be modified. I did not find anything in them that can be useful. 2. I can but I do not want to because I can get in trouble in case the mother company finds it "unsafe". 3. Simple reg/batch files are accepted until I can give an explanation to my boss in case I am asked. There have been cases when I have introduced simple portable exe files but only when a solution was requested on a problem and it was the only possible way of solving it. 4. To give you an idea,
dir
in system32 on the workstation takes ~20 seconds for 2470 files – Divin3 – 2016-02-15T09:45:09.843That doesn't leave too many possibilities for faster detection. Do progA/B lock exclusively any file? – harrymc – 2016-02-15T13:40:20.517
Or can you call progA/B this way : "prog 2>> file". This will lock the file exclusively, so your script can start prog if the file doesn't exist or if it's possible to delete it. – harrymc – 2016-02-15T16:22:02.057
@harrymc - I do not understand this method. Could you clarify it? – Divin3 – 2016-02-16T05:59:12.843
"prog 2>> file" launches the prog with redirection of the error file, also called stderr on Linux, on which normally nothing is written by most programs. While the program is running, the file is locked and cannot be deleted, since it is in use. If you can add "2>> file" to the program call, let me know and I will test it and add an answer detailing the method. See I/O Redirection and Pipes.
– harrymc – 2016-02-16T07:52:03.433@harrymc - yes it works, the file is created and is locked. Note that I will also need a method to be able to close the program without it starting automatically in case of maintenance. – Divin3 – 2016-02-16T08:43:26.687
I have added my answer. – harrymc – 2016-02-16T09:37:17.670
Just a quick hint - did you give the tool "AutoHotkey" a try? I've read cases where it could catch keys pressed which were not processed by the Windows Hotkey function. It's a little more complex solution, but you might give it a shot. – xpac – 2016-02-16T09:55:25.520
@xpac - I can not install third party programs because it is against the companies policy. – Divin3 – 2016-02-16T10:09:54.627