Old 3rd February 2012, 07:41   #1
castelinop
Junior Member
 
Join Date: Feb 2012
Posts: 3
Question 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.
castelinop is offline   Reply With Quote
Old 3rd February 2012, 08:31   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
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 )

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 4th February 2012, 20:55   #3
castelinop
Junior Member
 
Join Date: Feb 2012
Posts: 3
Thnx Anders, will look more into it.
castelinop is offline   Reply With Quote
Old 4th February 2012, 23:37   #4
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
You can format at the command line, too:
code:
# $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 is offline   Reply With Quote
Old 5th February 2012, 08:44   #5
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
demiller9: If by prompt you mean entering the volume label, you can use /V:label to enter it as a commandline parameter.
MSG is offline   Reply With Quote
Old 5th February 2012, 13:52   #6
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
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.
demiller9 is offline   Reply With Quote
Old 17th February 2012, 20:45   #7
castelinop
Junior Member
 
Join Date: Feb 2012
Posts: 3
Thumbs up Thank you

Quote:
Originally Posted by demiller9 View Post
You can format at the command line, too:
code:
# $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.
castelinop is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump