Autohotkey script to open command prompt

autohotkey, cmd, command-prompt

Solution

The command to run cmd.exe in the c:\ path is

run, cmd.exe, c:\

A full script that would run the cmd window every time would look like this

SetTitleMatchMode, 2
ifwinactive, ahk_class CabinetWClass
  ControlGetText, address , edit1, ahk_class CabinetWClass
else
  address =

; Exclude specific windows

ifwinactive, My Computer
  address =
ifwinactive, My Documents
  address =

if (address <> "") 
  Run, cmd.exe, %address%
else 
  Run, cmd.exe, C:\

ExitApp

Problem

I've collected a script from the `AutoHotKey` forum which lets me open a command prompt at the location I'm open in windows explorer. If the current window is not a explorer window then the prompt opens at the location where the script is present. I would like to change this behavior and make it open from `C:\` if the current window is not a explorer window. I've tried to edit the script but its not working as desired. ``` #ifwinactive, ahk_class CabinetWClass ControlGetText, address , edit1, ahk_class CabinetWClass if (address <> "") { Run, cmd.exe, %address% } else { Run, cmd.exe, "C:" } ExitApp #ifwinactive ```

Original source

Related problems