Configuring GuiCmd


Quotes

It's easy enough to add quotes around paths that need it, but you don't have to. If you turn on "Options / Quote Paths" it will add quotes around every path that gets added by the GUI. It saves a bit of fiddling and a few keystrokes.

Intrinsics

"Intrinsics" are built-ins. They are programs that GuiCmd knows about and can run for you with minimal typing. You can see the list of intrinsics at any time by clicking "Options / Intrinsics". That will open the list in Notepad for you. You can also edit it from there.

There is only one command that must be present in the intrinsics list:

*        = cmd /k %cmd% %args%

That should be the last line in the list. It matches anything you type in and then passes it to cmd.exe to run. The /k keeps the cmd window open after running the program. This seemed like a good default in case you want to read the results. You could change it to a /c to close the window immediately afterwards if that's a better default for you.

%cmd% will be replaced by the first word you enter in the text box. There is nothing fancy about this. The first word is everything up to the first space. It doesn't consider quotes or backslashes or any of the usual tricks.

%args% is the rest of the line after the first word.

Most intrinsics will look something like this:

cmdtwain = "c:\Program Files (x86)\GssEziSoft\CmdTwain\CmdTwain.exe" %args%

The pattern is (name) = (prog) %args% where (name) is what you type in to the text box and (prog) is the full path to the program to run. Normally (name) will be the same as the program name (CmdTwain in this example), but it doesn't have to be.

Another example is:

scan     = ""c:\Program Files (x86)\GssEziSoft\CmdTwain\CmdTwain.exe" /DPI=300 /JPG75 "%USERPROFILE%\Documents\%yyyy%-%mm%-%dd%.%h24%%m60% - %args%""

The are a few interesting things in this example.
For a start the (name) is "scan" but it runs "CmdTwain.exe".
You can also see a number of options (/DPI=300 /JPG75) being automatically included.
GuiCmd will also include timestamps if you need them.
%yyyy% becomes the 4-digit year (eg 2015)
%mm% becomes the month (01-12)
%dd% becomes the day (01-31)
%h24% is the hour (00-23)
%m60% is the minute (00-59)

You can also use %s60% for seconds (00-59), %h12% for hours (01-12) and %am% for "am" or "pm".

The next example shows running a command and then opening the output in Notepad.

dirlst   = cmd /c "dir %args% >"%TEMP%\filelist.txt" && notepad "%TEMP%\filelist.txt""

If you type dirlst in the input box and press ENTER (or click Run), it will run "dir" and place the output in a temporary file then open that file in Notepad.

Note that you can also use environment variables defined by Windows (%TEMP%) in a command line or in the intrinsic line.

NOTE: An important distinction in GuiCmd is that all of the internal variables (eg %yyyy%, %args%, etc) are CASE SENSITIVE. They must be lowercase. If you need to access a Windows environment variable that happens to have the same name, just use uppercase for the variable name. It won't be translated by GuiCmd. It will be passed unchanged to Cmd to process.