Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Using a AutoHotKey bind to execute a .bat file


  • Please log in to reply
4 replies to this topic
Jam0864
  • Members
  • 2 posts
  • Last active: May 04 2009 12:35 AM
  • Joined: 03 May 2009
I need to execute a .bat file using a bind.

The .bat file does it's job correctly when ran directly, but if I run it with a bind from AutoHotKey, it pops up, goes through it's stuff and closes as normal, but after it's closed none of the stuff it was meant to do actually got done.

This is the .bat file
IF EXIST TEST.TXT (GOTO SPEAKERS) ELSE (GOTO MICROPHONE)
:SPEAKERS
REGEDIT /s StereoMix.reg
ECHO Stereo Mix is now the default input device!
DEL TEST.TXT
GOTO END
:MICROPHONE
REGEDIT /s Microphone.REG
ECHO Microphone is now the default input device!
ECHO The current input device is the Microphone > TEST.TXT
:END

As you can see the main function is to apply some registry entries, but they don't get applied. I think it might be an authorisation issue, although I am using an administrator account on a Windows XP SP3 system. Is there a way I can give AutoHotKey administrative rights so it can apply some registry entries? (Assuming that's the problem)

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
A_WorkingDir ?

Jam0864
  • Members
  • 2 posts
  • Last active: May 04 2009 12:35 AM
  • Joined: 03 May 2009
I'm not on the same computer anymore, but it was something like this.

RAlt::Run C:\Documents and Settings\NAME\Desktop\Dsad.bat


New to this program so I don't really know what A_WorkingDir is or how to use it.

badmojo
  • Members
  • 204 posts
  • Last active: Apr 14 2014 01:08 AM
  • Joined: 11 Nov 2005
as mentioned by n-l-i-d, you may need to change the Run command's WorkingDir setting. if not, the script's folder is taken up as A_WorkingDir.

engunneer
  • Moderators
  • 9162 posts
  • Last active: Feb 27 2014 01:49 PM
  • Joined: 30 Aug 2005
example:
RAlt::Run C:\Documents and Settings\NAME\Desktop\Dsad.bat, C:\Documents and Settings\NAME\Desktop