Batch: start application doesn't show a GUI
-
14-11-2019 - |
문제
I try to launch a self written autoit application called "KeyShortcuts.exe" using a batch called "launchMacros.bat". This applications provides keyboard shortcuts for various things and includes a GUI which shows me the available shortcuts.
launchMacros.bat:
start "MyMacros" "M:\applications\AutoIt\KeyShortcuts.exe"
The application does start and I'm able to use every shortcut but I'm not able to see the GUI.
If I start the application direct (double click on KeyShortcuts.exe) everythings works fine.
I also tryed starting the application using runas:
runas /user:REQUIREDUSERNAME /savecred "M:\applications\AutoIt\KeyShortcuts.exe"
Same problem here. Even right click -> "Run as administrator" doesnt worked.
Any suggestions?
해결책
If your batch file is in a different directory than KeyShortcuts.exe
, you may need to specify the starting directory using the /D
parameter for START
.
Like this:
START "MyMacros" /D "M:\applications\AutoIt" "M:\applications\AutoIt\KeyShortcuts.exe"
다른 팁
Every batch file launched from Windows GUI create a new console window, run the batch file, then close. If you need this to be different, there's several ways:
- Create a shortcut to CMD /K YOURBATCHFILE.BAT
- Add a pause to your BAT file
Here's a demonstration of method 1:
- New > Shortcut
- Type the location of the item: C:\Windows\System32\CMD.EXE
- Type the name for this shortcut: InsertYourNameHere
- Click Finish
- Right click on your Shortcut and go properties
- Change Target to: C:\Windows\System32\CMD.EXE /K "InsertYourBatchFileName.BAT"
- Click OK
Done, now you have a shortcut that opens a new console window and leaves it open whilst ir runs your batch file.