Some of my batch files and scripts. Jump to the bottom for details about how I have set up my DOS environment as well as listing a few executable/utilities that are frequently used in my batch files.
- start_dos.bat » sets up my DOS environment. calls
alias.bat --load
andhistory.bat --load
to get things started. it then sets a bunch of envars and adds some paths to the PATH envar, etc. - exit_dos.bat » shuts down my DOS environment. calls
alias.bat --save
andhistory.bat --save
to get closed down. create an alias for 'exit' so that this file is called instead of just exiting the prompt; 'doskey exit %bin%\exit_dos.bat'. - Documentation
- alias.bat » allows using 'alias' like on Linux (all via DOSKEY). requires start_dos.bat and exit_dos.bat.
- Documentation
- hist.bat » calls history.bat.
- history.bat » allows using 'history' like on Linux. requires start_dos.bat and exit_dos.bat.
- Documentation
These have been deprecated in favor of the PowerShell
sudo
script. Execute the following to install it via scoop:
> scoop update
> scoop install sudo
- elevate.cmd » open the specified application with elevated permissions (run as administrator).
- elevate.vbs » this is NOT called directly. elevate.cmd calls this.
- Documentation
Simple menu system
- c.bat » cool little system menu and directory changing util.
Editors
- edit.bat » opens a text editor using the specified argument(s) if provided. Also replaces all '/' characters with '' and various other parsing enhancements. if
hosts
is the first argument, opens the machine's hosts file using sudo if available. - n.bat » calls 'edit.bat' with the editor being forced to Notepad2.
- notepad.bat » calls 'edit.bat' with the editor being forced to Notepad2.
- np.bat » calls 'edit.bat' with the editor being forced to Notepad++.
- open.bat » calls 'edit.bat'.
- subl.bat » calls 'edit.bat' with the editor being forced to Sublime Text.
- sublime.bat » calls 'edit.bat' with the editor being forced to Sublime Text.
Securely deleting files
- sdel.bat » calls 'sdelete.exe' with default arguments and the specified (arg1) number of passes.
- sdel1.bat » calls 'sdel.bat 1'.
- sdel5.bat » calls 'sdel.bat 5'.
- sdel8.bat » calls 'sdel.bat 8'.
- sdelete_prep.bat » deletes a ton of un-important (non-private) files using the standard DEL. i use this on a directory before securely deleting it, so that it is much faster.
- sdelete_repeater.bat » securely deletes all free space one pass at a time. it will not stop. (the reason for one pass in a loop, is if i execute 'sdelete -p 8 -c C:' the process may only have enough time to run get say 4 or 5 passes. using a single-pass in a loop i would get all free space hit 4 or 5 times, whereas the other way, i would only get half of the free space hit 8 times.)
DIR command wrappers
- dc.bat » lists files where name contains the value specified.
- dd.bat » lists (only) directories where name contains the value specified.
- de.bat » lists files where name (not including extension) ends with the value specified.
- ds.bat » lists files where name starts with the value specified.
- dx.bat » lists files where extension contains the value specified.
Misc. utilities
- ''.bat » changes to the root of the current drive (ie: 'cd').
- '.bat » changes to the current directories parent (ie: 'cd..'). did i mention that i'm lazy, yet?
- bigtext.bat » displays all arguments as very large, ASCII-based characters.
- cdor.bat » changes to first argument (a directory) that exists.
- cleanfree.bat » cleans (securely deletes) free space. requires 'sdelete.exe'.
- cleantemp.bat » cleans out some various temporary directories. will use 'sdelete.exe' if present.
- Cleanup-Setup.bat » configures 'cleanmgr.exe' (Cleanup Wizard) for use with 'Cleanup.bat'.
- Cleanup.bat » runs 'cleanmgr.exe' using the options specified via 'Cleanup-Setup.bat'.
- count.bat » counts the number of lines in the specified file and returns the count as the errorlevel.
- doserrors.bat » displays a list of all of the MSDOS extended error codes.
- emptybin.bat » empties the recycle bin. requires 'recycle.exe' or 'nircmd.exe'.
- get.bat » provides easy access to system information, such as 'get ip', 'get drives', 'get sid', etc.
- guid.bat » creates a new GUID and copies it to the clipboard. requires 'powershell'.
- hide.bat » shortcut to hide files and/or directories
- iiskill.bat » kill iis (internet information server).
- iisrestart.bat » restart iis. this is not the same as 'iisreset'. this restarts the iis admin process as well as the worker process(es).
- iisstart.bat » start iis (admin service) and the worker process(es).
- iisstop.bat » stop iis (admin service) and the worker process(es).
- killdead.bat » kills all applications (processes) that are not responding.
- killwebdev.bat » kills all WebDev.WebServer40.exe processes.
- nu.bat » simple wrapper for
net use
. yes. i am a lazy typer.. err.. typist. - ReplaceInFile.bat » replaces content in files.
- screensaver.bat » starts the screen saver.
- set_ipaddr_envar.bat » saves the current ip address to an environment variable.
- setdatevars.cmd » sets environment variables to the current date.
- settimevars.cmd » sets environment variables to the current time.
- unhide.bat » shortcut to show (unhide) files and/or directories
- wget+.bat » shows common usage of wget.exe.
I hate iTunes.
- itunes-start.bat » starts itunes' services and helper, then starts itunes itself.
- itunes-stop.bat » stops all of itunes' services, helper, and itunes itself.
The following batch files do a decent job of emulating linux commands in dos. For instance, common '--' arguments are supported and will convert forward slashes to back-slashes.
- cp.bat » copies files based on specified arguments.
- la.bat » lists files based on specified arguments.
- ll.bat » lists files based on specified arguments.
- lla.bat » lists files based on specified arguments.
- lls.bat » lists files based on specified arguments.
- ls.bat » lists files based on specified arguments.
- mv.bat » moves a file or files.
- pwd.bat » prints the working directory ('cd').
- rm.bat » deletes a file or files.
Also, check out the sections above on aliases and history.
Beyond Compare is one of maybe three apps that I use constantly for so much of my daily work! It rocks.
- bc.bat » provides a wrapper to find and execute BCompare.exe with the specified arguments. examples: 'bc C:\bin C:\bin-backup', 'bc \ .'. read this for the command-line details.
- bcscript.bat » enables the creation and use of .bcscript files that opened in BCompare.exe as a script file. read this for details about creating your own BC script files.
I have all but replaced these batch files with aliases (doskey macros). See 'Aliases (DOSKEY macros)' above for more details. I always come back to my batch files. They just work.
- git.bat » provides a wrapper to find and execute git.exe. also supports a 'purge' option. type
git --
to show all shortcuts. - ga.bat » adds files (ie: 'git.bat add [.|%*]'). if no argument is specified, it appends a dot ('.') for adding 'all'.
- gb.bat » branches (ie: 'git.bat branch %*').
- gc.bat » source checkout (ie: 'git.bat checkout %*').
- gd.bat » diff on the command-line (ie: 'git.bat diff %*').
- gdt.bat » diff using the 'difftool' (ie: 'git.bat difftool %*').
- gh.bat » shows the history (ie: 'git.bat log --oneline --graph --date=short --all --max-count=20 %*').
- gi.bat » commits changes (ie: 'git.bat commit %*').
- gitpatch.bat » saves a patch of changes to the desktop. can specify '--cached' or not. includes date/time in the filename.
- gl.bat » show logs (ie: 'git.bat log %*').
- gm.bat » merge using the 'mergetool' (ie: 'git.bat mergetool %*').
- gp.bat » pull (ie: 'git.bat pull %*').
- gs.bat » shows the status (ie: 'git.bat status %*').
- gz.bat » add specified file to .gitignore (ie: 'echo %1 >> .gitignore').
- svn.bat » provides a wrapper to find and execute svn.exe. type
svn --
to show all shortcuts. - sa.bat » adds files (ie: 'svn.bat add [.|%*]'). if no argument is specified, it appends a dot ('.') for adding 'all'.
- sb.bat » show who's to blame for changes to a file (ie: 'svn.bat blame %*').
- sd.bat » diff on the command-line (ie: 'svn.bat diff %*').
- si.bat » commits changes (ie: 'svn.bat commit %*').
- so.bat » source checkout (ie: 'svn.bat checkout %*').
- ss+.bat » shows the status, excluding ignored/untracked files (ie: 'svn.bat status --no-ignore %*').
- ss.bat » shows the status (ie: 'svn.bat status %*').
- va.bat » provides a wrapper to execute vagrant.exe. type
va --
to show all shortcuts. - vh.bat » stop/turn off the vagrant machine (ie: 'vagrant.bat halt %*').
- vr.bat » resumes the vagrant machine (ie: 'vagrant.bat resume %*').
- vs.bat » shows the status of the vagrant machine (ie: 'vagrant.bat status %*').
- vssh.bat » connect to the vagrant via SSH (ie: 'vagrant.bat ssh %*').
- vu.bat » start the vagrant (ie: 'vagrant.bat up %*').
- pdf2jpg.bat » creates a thumbnail of one or more pages within one or more .pdf files. This batch file is just an easy to use wrapper for the GhostScript command-line utility
gswin64c.exe
. - Documentation
- encrypt.bat » a simple wrapper for using openssl.exe to easily encrypt files.
- decrypt.bat » a simple wrapper for using openssl.exe to easily decrypt files.
- Documentation
- updatelinks.vbs » modifies multiple shortcut (.lnk) files' properties, including the target, arguments, directory, icon, and description.
- Documentation
This little utility is particularly useful as a Beyond Compare File Format.
- exportlink.vbs » updates the properties of the specified links (shortcuts) including the target, arguments, directory, icon, description, hotkey, and windowstyle.
- Documentation
- updatelinks.vbs » replaces properties of .lnk files.
- Documentation
- edpath.bat » easily edit the PATH environment variable with a few options (such as --prepend, --remove, --force, etc.).
- Documentation
- pathx.bat » easily display the PATH environment variable with each path on its own line.
Yes, I'm lazy. Actually, in this case, I am more forgetful than lazy, because I can never remember the arguments for shutdown.exe.
- shutdown.cmd » a simple utility to shutdown your computer. Please note, that shutdown.cmd will not be run unless '.cmd' shows up before '.exe' in your
PATHEXT
environment variable. - reboot.cmd » a simple utility to reboot/restart your computer.
- hibernate.cmd » a simple utility to hibernate your computer.
While I have tried to always make my batch files work in any environment, you may need to change some variables, envars, and/or paths to suit your needs and your computer environment.
This is where all of my utilities live (C:\bin). This includes my exe's and all of my batch and script files. Within this folder is an apps folder (%bin%\apps
). Any utility that is larger than one or two files, is put here with its own sub-directory (such as %bin%\apps\tcmd
). I create a .bat or .lnk file in %bin% to the utility's main exe buried in the sub-directory.
Generally, this is the same as %UserProfile%. The reason I have a separate envar is because I often am working on someone else's computer and launch a console window to use my tools. So, I can set
the profile path without affecting Windows' normal behavior, etc.
Note: I have started moving things back to %UserProfile%, instead of %Profile%.
This is where the big tools go. Applications such as mingw, Go, Git, Subversion, Mercurial, Google ADK, nodejs, Mono, Python, Perl, Chocolately (I never really got excited about Chocolately and don't use it anymore; scoop fits my style much better), Vagrant, and many more all go here. This folder is HUGE getting smaller as I use scoop for more and more packages.
I generally install tools in a 'version-less' folder, such as %tools%\mono
and %tools%\git
. I create a new directory under it with the version number in it, to use as a reference. For the rare occasion there is a need to simultaneously install multiple versions, I include the version in the directory name. The only example I have of that is Python 2.x and Python 3.x, which I install to %tools%\Python276
and %tools%\Python334
. (For my default Python version, I create an un-versioned junction that points to my default or standard version. In this case I point %tools%\Python
(junction) to %tools%\Python334
. See link below to download junction.exe.
Some of my batch and script files require additional (executable) utilities. These are listed here.
- cat.exe — I am referring to my version of cat.exe, because it does beautiful word-wrapping on the command-line.
- junction.exe — create directory junctions (ie: two different directory paths pointing to the same location/set of files). Download from Microsoft Sysinternals.
- sdelete.exe — permanently and securely delete your files. Download from Microsoft Sysinternals
- sleep.exe — I am referring to my version of sleep.exe, but any version will work assuming it's first argument is the number of milliseconds to wait before exiting.
- sort.exe — You can build/compile your own or download one of the many fine versions available. I prefer the mingw package, but that doesn't mean anything to anyone else. For convience, I have uploaded the sort.exe from my mingw installation to my Dropbox account. Download the official msys-coreutils-5.97-3 package or just sort.exe from my Dropbox. (NOTE: The Microsoft version of sort.exe works just fine, but the *nix version allows me to also remove duplicates.) Updated: scoop provides an easy way to install BusyBox, which includes sort.exe. install it using 'scoop update && scoop install BusyBox'.