Portable Freeware is an excellent site for downloading programs that will run portably from a USB thumb drive. If you download from that site as often as I do, no doubt you’ve seen instructions to create an empty file in the application’s folder so the application can save its settings to that file. This is often a tedious process as the only way I know of to do this is to drop to a command prompt and changing to the program’s folder so I can create the empty file using COPY CON. I decided to create an AutoIt script that makes this task much easier.
#FileZero.au3
$dir = FileSelectFolder(“Browse for folder.”, “”)
$fil=StringTrimLeft ($dir,3)
$file=inputbox (“FileZero”, “Enter filename or leave blank for ” & $fil & “.ini”)
if $file=”” Then
$file=$fil & “.ini”
endif
$writem = FileOpen($dir & “\” & $file, 2)
FileWrite($writem, “”)
FileClose($writem)
MsgBox(4096, “FileZero”, “Wrote ” & $file)
Here’s an AutoHotkey version of this same script.
#filezero.ahk
StringTrimLeft fil, dir, 3
InputBox file, FileZero, Enter filename or leave blank for %fil%.ini
if file =
file = %fil%.ini
FileAppend ,, %dir%\%file%
MsgBox Wrote %file%
When you run this script, you’ll start by browsing the folder tree to the folder where you want to create the empty file. By default, the empty file will have the name of the folder along with an INI extension.
For example, if you downloaded TinyTask, the mouse and keyboard macro recorder, you most likely saved that file to a folder called TinyTask. By default, the script will create an empty file called TinyTask.ini, which is what the program needs to save its settings portably.
In making this script, I had µTorrent in mind, which requires an empty file called settings.dat for it to run portably. I set up the script so you can specify the exact name of the empty file to create, or you can just leave the input window blank to have it create the INI file with the folder’s name as the file name. From there the script will create the empty file, ready for your portable application for computing on the go.
This script works best with simple folder structures, such as C:\TINYTASK, so it should work as planned with your thumb drive’s equally simple folder structure. The script went haywire when I tried navigating to one of the folders under “C:\Program Files”. It reported that it wrote the INI file but I could never find it. I’m not concerned with fixing that problem as there’s really no need to create empty files under Program Files.