4

I'm running AutoHotkey 1.0.48.05 on Windows 7 (64 bit).

I'd like CTRL-ALT-T to open the command prompt (such that it has the same Path / capabilities as when I open the command prompt manually).

This is what I have so far:

^!t::
    Run, cmd /k
Return

This successfully opens the command prompt, but it doesn't seem to have the %PATH% variable that I'd have if I go to Start > Run ... > cmd.exe.

For example, if I do CTRL-ALT-T and then type "java", I get:

'java' is not recognized as an internal or external command, operable program or batch file.

But if I use the Start > Run method, java works.

  • Where you have put the script file of AHK? Try to put it in the same path as open through the Run – avirk Sep 25 '12 at 7:05
  • I don't know what this means. I have the default file location: C:\Users\{user}\Documents\AutoHotkey.ahk And then that file does nothing other than an #Include of a file somewhere else. (I'm doing this to make it easier for my coworkers to share scripts.) – Ryan Sep 25 '12 at 20:26
  • Strange. You aren't opening an elevated prompt, are you? – surfasb Sep 26 '12 at 0:11
  • Try to put it in the C:` drive and then execute it. As I mean when we run the cmd` from RUN command then it ioen the command prompt window with the path C:\user\username> and if you have put the AHK in the path C:\Users\{user}\Documents` then it will open it. So try to put in the location from where you execute the Java`. Hope I'm clear now. – avirk Sep 26 '12 at 0:39
  • Now that I have Windows 10, what I do is press on the keyboard Win X, then A, then Yes. It opens the Command Prompt as an Administrator. – Ryan Jun 23 '18 at 14:07
2

I wrote the following script and it works perfectly on my system:

^!t::
    Run %WINDIR%\System32\cmd.exe /k
return

If you initially want to be in an specific folder (instead of AutoHotKey's installation folder) you can use "cd" command. For example, with the following script your command prompt will start in your Home folder:

^!t::
    Run %WINDIR%\System32\cmd.exe /k cd %USERPROFILE%
return

You can replace %USERPROFILE% with your desired destination folder.

  • Unfortunately this doesn't behave differently... same problem. Cool suggestion about the USERPROFILE though. – Ryan Sep 26 '12 at 18:56
1

Have you tried this?

^!t::Run, %comspec% /k

In any case, you can check the path by just typing PATH.

  • doesn't help, unfortunately – Ryan Sep 25 '12 at 17:21
0

I know this is a really old post but I just came across the answer to this, as I was having the same or similar problem.

Run %windir%\Sysnative\cmd.exe

Should solve the problem.

For more details, go here file system redirection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.