3

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?

Martin Brandl
  • 56,134
  • 13
  • 133
  • 172
  • I think you should clarify that START is from AutoIt not from Windows batch, since they're different things (Perhaps mention AutoIt in your title). The answers that are being posted assume the latter because of this ambiguity. – Stephen Quan Jan 27 '12 at 11:48
  • 1
    Okay, there's some detail missing. I'm not sure what, perhaps some clarification on what "MyMacros" is in your script and what your KeyShortcuts.exe application actually does. If you can provide a simplified version of it here to share it will help us research your problem better. – Stephen Quan Jan 27 '12 at 12:46
  • @BicycleDude `"MyMacros"` is the title parameter for the `START` command. – aphoria Jan 27 '12 at 14:20
  • Because you're using AutoIt. Have you tried an AutoIt script that invokes your AutoIt KeyShortcuts.exe applciation? – Stephen Quan Jan 27 '12 at 14:29
  • Did you compile the script with a console output? Try it, it probably helps you out while starting it from a cmd. – Samoth Jan 29 '12 at 21:57

2 Answers2

4

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"
aphoria
  • 19,796
  • 7
  • 64
  • 73
1

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:

  1. Create a shortcut to CMD /K YOURBATCHFILE.BAT
  2. Add a pause to your BAT file

Here's a demonstration of method 1:

  1. New > Shortcut
  2. Type the location of the item: C:\Windows\System32\CMD.EXE
  3. Type the name for this shortcut: InsertYourNameHere
  4. Click Finish
  5. Right click on your Shortcut and go properties
  6. Change Target to: C:\Windows\System32\CMD.EXE /K "InsertYourBatchFileName.BAT"
  7. Click OK

Done, now you have a shortcut that opens a new console window and leaves it open whilst ir runs your batch file.

Stephen Quan
  • 21,481
  • 4
  • 88
  • 75