Run cmd has an unexpected result

Get help with using AutoHotkey and its commands and hotkeys
afe
Posts: 618
Joined: 06 Dec 2018, 04:36

Run cmd has an unexpected result

05 Jul 2020, 02:48

Code: Select all

Run, cmd /K
Usually, the current directory will be displayed when this command is completed, but the result obtained by someone is
C:\Windows\System32

Why is that?

This will cause a error "The system cannot find the path specified." when running other programs in the current directory of the script, such as

Code: Select all

Run, cmd /K appA\appA.exe
Because the program may mistakenly think that appA is in C:\Windows\System32, not in the script directory.

Assume that appA is a directory under the root directory of the script.

I don’t know why the same Windows version will produce different results when executing Run, cmd. Can anyone explain?
garry
Posts: 2460
Joined: 22 Dec 2013, 12:50

Re: Run cmd has an unexpected result

05 Jul 2020, 03:02

example DOS is in a_scriptdir

Code: Select all

setworkingdir,%a_scriptdir%
run,%comspec% /k
exitapp
afe
Posts: 618
Joined: 06 Dec 2018, 04:36

Re: Run cmd has an unexpected result

05 Jul 2020, 03:32

I don't think it has anything to do with the working directory. The working directory impact will be CMD, and CMD is not in the script directory, nor will it affect the subsequent appA.

The problem should be what caused the directory displayed after 'Run, cmd' to be 'C:\Windows\Systme32' instead of the current script directory.

I cannot reproduce 'C:\Windows\System32' on my computer. I use Windows 8.1, but someone with this problem also uses Windows 8.1. This is confusing.

And I don't think the following writing will help.

Code: Select all

Run, C:\Windows\System32\cmd /K appA\appA.exe

I have tested on a newly installed Windows 8.1
Run, cmd /K
, The same result will not appear
C:\Windows\System32

Return to “Ask For Help”

Who is online

Users browsing this forum: Bibliocrat, Bing [Bot], grimboto, JoeWinograd, mikeyww and 51 guests