Jump to content
Sign in to follow this  
Simplify iT

Automatically Delete The Disk Volume Name

Recommended Posts

Simplify iT

Hi All,

I am very new to Autoit and thought i would ask the script masters for some help.

What i am looking to do is be able to delete the current disk forum name for drive f:

I have attempted to do this with the command line "label.exe" tool, however it requires user interaction and i want to make this hands free.

So ideally i need a script that i can add the drive like delvol.au3 d (to delete the volume name from drive d:)

Can anyone tell me if this can be done and how i might do it?

Cheers,

Darren

Share this post


Link to post
Share on other sites
Uten

Do you want to detache (as in hide) the volume or do you want to wipe it?

Is it a removable volume?

Share this post


Link to post
Share on other sites
CyberSlug

Might work:

#include <Process.au3>
_RunDOS( "label F: TheNewName" )

EDIT: Wait, I see what you mean about requiring interaction when the new label is blank!

You could use the StdinWrite function (requires beta version of AutoIt).

#include <Constants.au3>
$pid = Run("label.exe d:", "", @SW_HIDE, $STDIN_CHILD)
StdinWrite($pid, @CRLF & "y" & @CRLF);Enter, Yes, Enter

To specify drive letter on command line

#include <Constants.au3>
If $CmdLine[0] = 0 Then Exit
$driveLetter = $CmdLine[1]
$pid = Run("label.exe " & $driveLetter, "", @SW_HIDE, $STDIN_CHILD)
StdinWrite($pid, @CRLF & "y" & @CRLF);Enter, Yes, Enter

Here's an alternative method seems to work on Windows XP (also requires beta version:

$driveLetter = "D:"
$oShell = ObjCreate("shell.application")
$oShell.NameSpace($driveLetter).Self.Name = ""

If you want to pass the drive letter on the command line, then you could replace the first line with:

$driveLetter = ""

If $CmdLine[0] > 0 Then $driveLetter = $CmdLine[1]

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites
NightGaunt

$var = "F:"
DriveSetLabel ( $var, "" )

That will Empty the label; is that it?


"I have discovered that all human evil comes from this, man's being unable to sit still in a room. " - Blaise Pascal

Share this post


Link to post
Share on other sites
sykes

If you want to change the label using a command line switch use the following:

If $cmdline[0] <> "" Then
    If $cmdline[0] = 2 Then
        $drv = $cmdline[1]
        $label = $cmdline[2]
        DriveSetLabel($drv & ":", $label)
    EndIf
EndIf

usage is:

delvol [drive letter] [label name]

Examples:

delvol c Main

changes the label for drive c to "Main"

delvol f ""

removes the label for drive f

hope this helps


We have enough youth. How about a fountain of SMART?

Share this post


Link to post
Share on other sites
Simplify iT

$var = "F:"
DriveSetLabel ( $var, "" )

That will Empty the label; is that it?

thats exactly what i am looking for - thanks so much!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.