Required software

Download

Example usage

An example of how these scripts can be used is to create a virtual SD card file (sd.raw) for use with Dolphin Emulator, without having to download unnecessary shareware. (see: WinImage)

To use, simply get all the required software, download and unzip the build package into a folder, and then edit the following variables in settings.bat:

SD_CARD_PATH
It will usually look something similar to C:\Users\PROFILE\Documents\Dolphin Emulator\Wii\sd.raw

SD_CARD_MOUNT_DRIVE_LETTER
The drive letter the file should be mounted to when editing

SD_CARD_SIZE
The size (in MiB) of the virtual SD card file

SD_CARD_LABEL
The desired label as it appears under “Computer” and other places

To edit SD card contents, run create.bat followed by mount.bat (for subsequent editing, only mount.bat needs to be executed.)
Then place any files on the newly added disk under “Computer”.
After editing is complete, run unmount.bat to allow other applications read/write access on the virtual SD card file.

Note that the same general setup can be used for other applications with a little tweaking; it's designed to be fairly generic.

Batch files

settings.bat – Contains various settings which are used in all of the other .bat scripts. The section at the top should be edited as desired.

create.bat – Creates a new virtual disk file and formats it. If the target path already exists, the user is prompted if it should re-create the file. Additionally, a shortcut to the parent directory of the new file is created.

delete.bat – Deletes the virtual hard disk file, along with the shortcut to its parent directory. If the file is currently mounted, it must be unmounted before deletion will work.

mount.bat – Attempts to mount the virtual disk file to a volume and apply a new letter to it. Additionally creates a shortcut to the new drive letter for ease of access.

unmount.bat – Attempts to unmount the virtual disk file. The shortcut to the drive letter will also be deleted on a successful unmounting.

vsd.py

vsd.py is the main script used for creating, deleting, mounting, and unmounting virtual disk files. It can perform up to 4 of the commands in one execution.

Descriptions of the command line flags and commands follow. Additional info can be obtained by executing vsd.py --usage.

Commands

If multiple commands are specified, they will be executed in the order: --unmount, --delete, --create, --mount.
They are not executed in the order they appear on the command line.

--create – Creates a new virtual disk file
If the file already exists, it will not be overwritten.Uses: --path; Optional --size, --label, --file-system

--delete – Deletes a virtual disk file
If the file is mounted, it will not be deleted.Uses: --path

--unmount – Unmounts a virtual disk file
If --letter is specified, the disk will only unmount if it is mounted to the specified letter.Uses: --path; Optional: --letter

Flags

--path <value> – The path to the virtual disk file

--size <value> – The virtual disk size in MiB

--label <value> – The disk label used during formatting

--letter <value> – The drive letter a virtual disk file should be mounted to

--file-system <value> – A file system such as FAT, FAT32, NTFS, etc.
If omitted, it will be the default option DiskPart uses (sometimes unformatted)See DiskPart “FILESYSTEMS” command for more info

shortcut.py

shortcut.py is responsible for creating and deleting shortcut. It is designed to be able to create file shortcuts and URI shortcuts as well. It can be used as an imported library, and as such, some of its functionality is not used by the included batch scripts.

Initially, shortcut.py was designed to use the pywin32 extensions to help create shortcuts, but it has problems creating directory shortcuts this way. The code remains in the file, but it is never used.

Command line

The general format of the command line usage is:shortcut.py [input_arguments] output_filename.lnk target.ext [shortcut_arguments]

Once filename and target have been specified (either by --flagged or flagless arguments,) all remaining arguments are used as the arguments of the shortcut file.

Command line flags

Additional info can be obtained by executing shortcut.py --usage.

--icon <value> – A path to an icon file, or a file containing icons

--icon-index <value> – The index of the icon within a file, in case there are multiple icons

--working-directory <value> – The working directory the shortcut should start in

--target <value> – The target file or URI the shortcut should point to

--filename <value> – The output filename of the shortcut
If --target is a local file, the filename will end with .lnk.
If --target is any other URI, the filename will end with .url.