Archive: Let NSIS format USB


Let NSIS format USB
Hi,
Using NSIS I have made an installer that lets the user browse to their USB drive and installs my files/folders on the USB's root directory.

But I want to go a step further and instead of the user having to format their USB drive manually beforehand, I want my installer to format it for them.

That is my installer will format the USB drive and then put my files/folders on the USB drive. I would like to know how do I go about doing this and links to any references will be greatly appreciated.

Thanks.


I'm guessing you would have to call SHFormatDrive or FormatEx ( http://www.ureader.com/msg/1474253.aspx http://forum.sysinternals.com/create...338_page4.html ftp://ftp.decus.org/decus/vms/sig_ta...b/nt/fmifs.htm ) or IOCTL_DISK_SET_DRIVE_LAYOUT with the system plugin or use WMI ( http://msdn.microsoft.com/en-us/libr...2#Win32_Volume )


Thnx Anders, will look more into it.


You can format at the command line, too:

# $USB is the drive letter, $USBVolName is the new name we want to assign
ExpandEnvStrings $0 %COMSPEC%
nsExec::Exec `"$0" /c echo. | Format $USB /Q /X /V:$USBVolName`
Pop $0 ; get the result code (0 = good)
The "echo. |" sends an Enter key to the prompt it asks.

demiller9: If by prompt you mean entering the volume label, you can use /V:label to enter it as a commandline parameter.


MSG: the prompt is "Insert new disk for drive X: and press ENTER when ready" (a chance to *not* format the wrong drive). I already have the /V switch.


Thank you

Originally posted by demiller9
You can format at the command line, too:
# $USB is the drive letter, $USBVolName is the new name we want to assign
ExpandEnvStrings $0 %COMSPEC%
nsExec::Exec `"$0" /c echo. | Format $USB /Q /X /V:$USBVolName`
Pop $0 ; get the result code (0 = good)
The "echo. |" sends an Enter key to the prompt it asks.
Thanks demiller9, it was what I needed. Once I knew the syntax to call up the command line I could customize it to me need.