Can AHK run CMD silent? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

Can AHK run CMD silent?

Post by Evil-e » 20 Oct 2022, 18:08

(EDITED TO CORRECT ERROR OF FALSELY IDENTIFYING SPECIAL CHARACTER AT FAULT)

I use AHK all over the place on my PC and have a few folders with special characters. I prefer to use batch files to open folders, but have done a LOT of research and no luck finding a way to escape a couple pesky characters :headwall: The following script (I have a handful of others), not only opens the folder upon end of gameplay, but also deletes some junk cache files that were created while playing it. Works great, but would prefer to run these commands silently and not with a fullscreen blue CMD window typing it all out in front of me. Ya, this qualifies as a first world problem :HeHe:

I am now seeking a way to ideally run CMD completely silent, as .vbs does with a .bat file. As per usual, I have done research, but cannot find anything that will accomplish my goal:
------------------------------------------------------------------------------------------------------------------------------------------------

Code: Select all

    sleep, 1000
    Run, C:\WINDOWS\system32\Commandmeister.exe                                                             ;this is CMD.exe renamed
    sleep, 10
    send cd /d "C:\Documents and Settings\Eric\Application Data\Sunward Games\Endless Fables - The Minotaur’s Curse\CE\profile"{enter}
    sleep, 10
    send del 4576696C65.ach.bak{enter}
    sleep, 10
    send del Profile_01_bak.prf{enter}
    sleep, 10
    send del Save_GameContent_SE01_bak.cub{enter}
    sleep, 10
    send del Save_GameContent_CE01_bak.cub{enter}
    sleep, 50
    Run, C:\Documents and Settings\Eric\Application Data\Sunward Games\Endless Fables - The Minotaur’s Curse
    sleep, 50
    Run, G:\Games\+ DaS - Eric - AD\Sunward Games\Endless Fables - The Minotaur’s Curse
    sleep, 50
    Process, Close, Commandmeister.exe
----------------------------------------------------------------------------------------------------------------------------------------------
The character is the "’" (used as apostrophe) but I don't know what it is. I even contacted Rob van der Woude (has website and specializes in batch file commands) and his suggestion did not work* :( This is why I am back to hoping AHK can do the above task silently.

As always, I appreciate any input or thoughts you may have. I am hoping there is some text I can add to my script to accomplish my task

:morebeard:

PS> I can probably get CMD.exe to always run silent, but only wish to do so for specific situations like this :angel:
PPS> Now that I have expressed all this, I have a couple ideas for research, so I will continue to look 8-)

* Rob van der Woude opted to reach back out to me and did indeed resolve THIS specific issue, but there are a number of other folders with special characters that his option did not resolve
Last edited by Evil-e on 21 Oct 2022, 11:55, edited 1 time in total.
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Can AHK run CMD silent?

Post by Lepes » 21 Oct 2022, 03:47

If you just need to delete some files you can use native AHK FileDelete or FileRecycle.

Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

Re: Can AHK run CMD silent?

Post by Evil-e » 21 Oct 2022, 10:15

Lepes... you are an AHK GOD :bravo:

I seriously do a lot of research before I ask questions, but AHK surprises me endlessly! I always go through the docs and I just miss stuff that is right there :shock: I have always written batch files to delete cache files / folders, so this is just one MORE way that AHK is probably my fave program of all time. It is simply not possible to say how much this little (meaning light-weight) program has improved my PC experience. I have a number of games that I would NEVER have kept, had it not been for the abilities this program can do.

I was able to find FileRemoveDir, to delete folders, so my search skills are improving :HeHe:

Again... MANY thanks for your help, Lepes. I will keep a copy of this little script in my "help files" folder for future reference :beer:

:morebeard:

PS> Something just occurred to me. I bet here is also an "open folder" command, so that would be golden [hits up the docs] :thumbup:
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Can AHK run CMD silent?

Post by Lepes » 21 Oct 2022, 11:49

Evil-e wrote:
21 Oct 2022, 10:15
PS> Something just occurred to me. I bet here is also an "open folder" command, so that would be golden [hits up the docs] :thumbup:

Code: Select all


Run, %A_Desktop%
Run, c:\   ; You can change for any other folder path on your computer.
Run, %A_MyDocuments%
Run, %A_MyDocuments%\Downloads  ; mix variables with any other folder name you know it already exists.
https://www.autohotkey.com/docs/Variables.htm#os

Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

Re: Can AHK run CMD silent?

Post by Evil-e » 21 Oct 2022, 17:07

Well, I tried EVERY possible combination of %A_MyDocuments% (including folder names within the directory path) that made any sense to me. Tried with / without C:\, with without % or " and searched the docs, but after at solid 20~25 attempts, the closest I got once, was opening Documents and Settings root directory one time. I tinkered around with THAT syntax as far as I could think and unable to get AHK to open a special character folder. On the upside, deleting files / folders within that special character directory is no longer an issue, because in addition to Lepes FileDelete suggestion, I then found FileRemoveDir, and with the addition of ", 1" will delete any contents as well.
----------------------------------------------------------------------------------------------------------------------------

Code: Select all

    sleep, 1000
    Run, C:\WINDOWS\system32\Commandmeister.exe                                                             ;this is CMD.exe renamed
    sleep, 50
    Run, C:\Documents and Settings\Eric\Application Data\Sunward Games\Endless Fables - The Minotaur’s Curse <----- the "apostrophe" is the problem
    sleep, 50
    Run, G:\Games\+ DaS - Eric - AD\Sunward Games\Endless Fables - The Minotaur’s Curse
    sleep, 50
    Process, Close, Commandmeister.exe
----------------------------------------------------------------------------------------------------------------------------
(this is a condensed version of the script OP script above, but has the path I wish to open via AHK script)
If I could get some additional help on how to open a special character directory via AHK, I would be most appreciative :dance:

Thanks to any and all for your thoughts :morebeard:
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Can AHK run CMD silent?

Post by Lepes » 22 Oct 2022, 03:11

I use Spanish keyboard and I don't know all this "accent" keys on English keyboard, and how to use it.

EscapeChar

try several times with Msgbox until it shows the tilde, accent char or whatever is called.
I know you used a different char because I tried to copy and paste your code, but since it uses a special char, I need to save your script with "UTF8 with boom", the character I copied from your script didn't show well on my editor.
Maybe you need to type this char: ` and then the special char.

Code: Select all

msgbox, C:\Documents and Settings\Eric\Application Data\Sunward Games\Endless Fables - The Minotaur`s ; FAIL The char is omitted on the Message.
msgbox, C:\Documents and Settings\Eric\Application Data\Sunward Games\Endless Fables - The Minotaur``s  ; OK , you need to duplicate this one
msgbox, C:\Documents and Settings\Eric\Application Data\Sunward Games\Endless Fables - The Minotaur's ; OK , it is a different character so it works.

User avatar
rommmcek
Posts: 1480
Joined: 15 Aug 2014, 15:18

Re: Can AHK run CMD silent?

Post by rommmcek » 22 Oct 2022, 05:30

@Evil-e: To further automate your task you might be interested in WatchFolder().

Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

Re: Can AHK run CMD silent?

Post by Evil-e » 22 Oct 2022, 09:04

Thank you both, @rommmcek & @Lepes :)

I got a little ahead of myself, in that I asked how to open a folder with a special character (yes.... Lepes, I think you are correct that it is a tilde), when I need to begin at the more simplified..."how do I open a folder" :HeHe: I dug around in docs and the closest thing I can find is FileSelectFolder,

https://www.autohotkey.com/docs/commands/FileSelectFolder.htm

I have navigated to many of the commands on that page and those it sends me to and just when I think I hit a home run.... the super-human acrobat roaming left field scales the wall and robs me :cry: So I am hoping someone can point me to the docs that shows how to simply open a folder on my drive, I can start there and address any special character issues :thumbup:

:morebeard:
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Can AHK run CMD silent?

Post by Lepes » 22 Oct 2022, 11:02

I hate FileSelectFolder. The folder I want to open is just too far away.

How many folders Do you use frecuently? I gues 20, 30; it doesn't count those folders that are one level of distance from another one.

I use FreeCommander with 5 preconfigured design (a design can contain multiples file folder tabsheets at both panels), If I need the path and or filename, I just copy from FreeCommander toolbar ( Alt + Insert) and paste the full path into any "Open File" dialog. That's it. I never use a Treeview or navigate folders by hands.

You can do:
- an AHK Gui with "favorite folders" buttons.
- Use Radial Menu
- FreeCommander "Favorites folder panels" or designs

On the other side, about special chars, I finally uninstall and reinstall on a different folder without special chars. That's what I do, but I'm sure someone could point you on another solution.

Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

Re: Can AHK run CMD silent?  Topic is solved

Post by Evil-e » 22 Oct 2022, 12:18

OMG... I am such a dummy! Forest for the trees, eh? :oops:

Problem solved and opens folder with special characters as well.... DOH!
---------------------------------------------------------------------------------------------------------------------------------
run, C:\Documents and Settings\Eric\Application Data\Sunward Games\Endless Fables - The Minotaur’s Curse
---------------------------------------------------------------------------------------------------------------------------------

Thanks @Lepes... but this is a game save folder, so I cannot change the name. I use AHK on all of my games, so that when I exit gameplay, the AHK script will launch a batch file to open the save folder and a second folder (separate drive) to back up that game save file.

The problem becomes when a batch cannot open the save folder, due to that special character. I am also working on batch scripting, so that might pan out... don't know. However, it would be really quick and convenient to just script AHK and open that folder directly, if it can.

I appreciate the suggestions, but I don't want to install a new program just for this task. Worst case scenario, I continue to use AHK launching CMD.exe for those 15 or so folders :D I will keep looking, because AHK can do just about anything but make my breakfast, so it has to be able to do a basic opening of a folder.. right? :lol:

:morebeard:

PS> I will continue looking and check the GUI section again for your "Favorite Folders" buttons. If AHK can open a folder, I can make that work!
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)

Emile HasKey
Posts: 27
Joined: 06 Mar 2022, 17:45

Re: Can AHK run CMD silent?

Post by Emile HasKey » 13 Nov 2022, 17:13

I'm using Windows 10.
I created 2 text files and a link file on my desktop, then I created 3 batch files saved as UTF-8 with BOM, each with one of these lines:

Code: Select all

start "notepad.exe" "C:\Users\%username%\Desktop\New Text Document.txt"
start "explorer.exe" "C:\Users\%username%\Desktop\New Text Document - Shortcut.lnk"
start "notepad.exe" "C:\Users\%username%\Desktop\my file with Chr(8217) ’.txt"
All of the batch files opened the files successfully.

Even if you couldn't open a file directly, because of a special character, couldn't you open a link to it instead? A link that only uses ASCII characters in its filename.
Another possibility, maybe use a short-form path? Also known as an '8.3' path.

Post Reply

Return to “Ask for Help (v1)”