[DISKPART] Implement the assign command

- Also improve the parameter checks of the remove command.

The assign command does not work, because the SetVolumeMountPointW function is not implemented yet.
This commit is contained in:
Eric Kohl
2025-12-28 20:35:27 +01:00
parent c8e1772109
commit f6a86c1ab3
15 changed files with 645 additions and 21 deletions
+145 -1
View File
@@ -8,7 +8,151 @@
#include "diskpart.h"
BOOL assign_main(INT argc, LPWSTR *argv)
#define NDEBUG
#include <debug.h>
BOOL
assign_main(
_In_ INT argc,
_In_ LPWSTR *argv)
{
WCHAR szMountPoint[4];
PWSTR pszSuffix = NULL;
WCHAR DriveLetter = UNICODE_NULL;
INT i, nExclusive = 0;
BOOL bResult;
DPRINT1("assign_main()\n");
if (CurrentVolume == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_VOLUME);
return TRUE;
}
for (i = 1; i < argc; i++)
{
if (_wcsicmp(argv[i], L"noerr") == 0)
{
/* noerr */
DPRINT("NoErr\n", pszSuffix);
ConPuts(StdOut, L"The NOERR option is not supported yet!\n");
#if 0
bNoErr = TRUE;
#endif
}
}
for (i = 1; i < argc; i++)
{
if (HasPrefix(argv[i], L"letter=", &pszSuffix))
{
if (wcslen(pszSuffix) == 1)
{
DriveLetter = towupper(*pszSuffix);
nExclusive++;
}
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
}
}
else if (HasPrefix(argv[i], L"mount=", &pszSuffix))
{
DPRINT("Mount\n", pszSuffix);
ConPuts(StdOut, L"The MOUNT option is not supported yet!\n");
nExclusive++;
}
else if (_wcsicmp(argv[i], L"noerr") == 0)
{
/* noerr - Already handled above */
}
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
}
}
if (nExclusive > 1)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
}
DPRINT1("VolumeName: %S\n", CurrentVolume->VolumeName);
DPRINT1("DeviceName: %S\n", CurrentVolume->DeviceName);
DPRINT1("DriveLetter: %C\n", CurrentVolume->DriveLetter);
if (DriveLetter != UNICODE_NULL)
{
DPRINT1("DriveLetter: %C\n", DriveLetter);
if ((DriveLetter < L'C') || (DriveLetter > L'Z'))
{
ConResPuts(StdOut, IDS_ASSIGN_INVALID_LETTER);
return TRUE;
}
if (DriveLetter == CurrentVolume->DriveLetter)
{
ConResPuts(StdOut, IDS_ASSIGN_ALREADY_ASSIGNED);
return TRUE;
}
}
if (CurrentVolume->DriveLetter != UNICODE_NULL)
{
/* Remove the current drive letter */
szMountPoint[0] = CurrentVolume->DriveLetter;
szMountPoint[1] = L':';
szMountPoint[2] = L'\\';
szMountPoint[3] = UNICODE_NULL;
bResult = DeleteVolumeMountPointW(szMountPoint);
if (bResult == FALSE)
{
ConResPuts(StdOut, IDS_ASSIGN_FAIL);
return TRUE;
}
CurrentVolume->DriveLetter = UNICODE_NULL;
}
if (DriveLetter != UNICODE_NULL)
{
/* Assign the new drive letter */
szMountPoint[0] = DriveLetter;
szMountPoint[1] = L':';
szMountPoint[2] = L'\\';
szMountPoint[3] = UNICODE_NULL;
bResult = SetVolumeMountPointW(szMountPoint,
CurrentVolume->VolumeName);
if (bResult == FALSE)
{
ConResPuts(StdOut, IDS_ASSIGN_FAIL);
return TRUE;
}
CurrentVolume->DriveLetter = DriveLetter;
}
else
{
/* TODO: Assign the next drive letter */
#if 0
bResult = SetNextDriveLetter(CurrentVolume->VolumeName,
&CurrentVolume->DriveLetter);
if (bResult == FALSE)
{
ConResPuts(StdOut, IDS_ASSIGN_FAIL);
return TRUE;
}
#endif
}
ConResPuts(StdOut, IDS_REMOVE_SUCCESS);
return TRUE;
}
+335 -10
View File
@@ -310,34 +310,359 @@ SymbolicName=MSG_COMMAND_ASSIGN
Severity=Informational
Facility=System
Language=English
<Add ASSIGN command help text here>
Assigns a drive letter or mounted folder pathname to the volume with focus.
Syntax: ASSIGN [LETTER=<D> | MOUNT=<PATH>] [NOERR]
LETTER=<D> The drive letter to assign to the volume.
MOUNT=<PATH>
The mounted folder pathname to assign to the volume.
NOERR For scripting only. When an error is encountered, DiskPart
continues to process commands as if the error did not occur.
Without the NOERR parameter, an error causes DiskPart to exit
with an error code.
If no drive letter or mounted folder is specified, the next available drive
letter is assigned. If the drive letter or mounted folder is already in use,
an error is generated.
By using the ASSIGN command, you can change the drive letter associated
with a removable drive.
You cannot assign drive letters to boot volumes or
volumes that contain the paging file. In addition, you cannot assign
a drive letter to an Original Equipment Manufacturer (OEM) partition
unless booted to Windows PE, or any GUID Partition Table (GPT) partition
other than a basic data partition, an ESP partition or a recovery
partition.
A volume must be selected for this operation to succeed.
Example:
ASSIGN LETTER=D
.
Language=German
<Add ASSIGN command help text here>
Weist dem Volume mit dem Fokus einen Laufwerkbuchstaben oder
den Pfadnamen des eingebundenen Ordners zu.
Syntax: ASSIGN [LETTER=<D> | MOUNT=<PATH>] [NOERR]
LETTER=<D> Der Laufwerkbuchstabe, den Sie dem Volume zuweisen
möchten.
MOUNT=<PATH>
Der Pfadname des eingebundenen Ordners, den Sie dem Volume
zuweisen möchten.
NOERR Nur für Skripting. Bei einem Fehler wird die Verarbeitung
von Befehlen fortgesetzt, als sei der Fehler nicht aufge-
treten. Ohne den NOERR-Parameter wird "DiskPart" bei
einem Fehler mit dem entsprechenden Fehlercode beendet.
Wenn kein Laufwerkbuchstabe oder eingebundener Ordner angegeben ist,
wird der nächste verfügbare Laufwerkbuchstabe zugewiesen. Ein Fehler
wird generiert, wenn der Laufwerkbuchstabe oder Bereitstellungspunkt
bereits verwendet wird.
Mit dem Befehl "ASSIGN" können Sie den Laufwerkbuchstaben ändern,
der einem Wechseldatenträger zugeordnet ist.
Startvolumes oder Volumes, die die Auslagerungsdatei
enthalten, können keine Laufwerkbuchstaben zugewiesen werden. Dar\xFCber
hinaus können Laufwerkbuchstaben weder OEM-Partitionen
(sofern kein Start in Windows PE erfolgt) noch GPT-Partitionen (GUID-
Partitionstabelle) zugewiesen werden, die keine Basisdatenpartitionen,
ESP-Partitionen oder Wiederherstellungspartitionen sind.
Damit dieser Vorgang erfolgreich ausgeführt werden kann, muss ein
Volume ausgewählt werden.
Beispiel:
ASSIGN LETTER=D
.
Language=Polish
<Add ASSIGN command help text here>
Assigns a drive letter or mounted folder pathname to the volume with focus.
Syntax: ASSIGN [LETTER=<D> | MOUNT=<PATH>] [NOERR]
LETTER=<D> The drive letter to assign to the volume.
MOUNT=<PATH>
The mounted folder pathname to assign to the volume.
NOERR For scripting only. When an error is encountered, DiskPart
continues to process commands as if the error did not occur.
Without the NOERR parameter, an error causes DiskPart to exit
with an error code.
If no drive letter or mounted folder is specified, the next available drive
letter is assigned. If the drive letter or mounted folder is already in use,
an error is generated.
By using the ASSIGN command, you can change the drive letter associated
with a removable drive.
You cannot assign drive letters to boot volumes or
volumes that contain the paging file. In addition, you cannot assign
a drive letter to an Original Equipment Manufacturer (OEM) partition
unless booted to Windows PE, or any GUID Partition Table (GPT) partition
other than a basic data partition, an ESP partition or a recovery
partition.
A volume must be selected for this operation to succeed.
Example:
ASSIGN LETTER=D
.
Language=Portugese
<Add ASSIGN command help text here>
Assigns a drive letter or mounted folder pathname to the volume with focus.
Syntax: ASSIGN [LETTER=<D> | MOUNT=<PATH>] [NOERR]
LETTER=<D> The drive letter to assign to the volume.
MOUNT=<PATH>
The mounted folder pathname to assign to the volume.
NOERR For scripting only. When an error is encountered, DiskPart
continues to process commands as if the error did not occur.
Without the NOERR parameter, an error causes DiskPart to exit
with an error code.
If no drive letter or mounted folder is specified, the next available drive
letter is assigned. If the drive letter or mounted folder is already in use,
an error is generated.
By using the ASSIGN command, you can change the drive letter associated
with a removable drive.
You cannot assign drive letters to boot volumes or
volumes that contain the paging file. In addition, you cannot assign
a drive letter to an Original Equipment Manufacturer (OEM) partition
unless booted to Windows PE, or any GUID Partition Table (GPT) partition
other than a basic data partition, an ESP partition or a recovery
partition.
A volume must be selected for this operation to succeed.
Example:
ASSIGN LETTER=D
.
Language=Romanian
<Adăugați aici textul de ajutor pentru comanda ASSIGN>
Assigns a drive letter or mounted folder pathname to the volume with focus.
Syntax: ASSIGN [LETTER=<D> | MOUNT=<PATH>] [NOERR]
LETTER=<D> The drive letter to assign to the volume.
MOUNT=<PATH>
The mounted folder pathname to assign to the volume.
NOERR For scripting only. When an error is encountered, DiskPart
continues to process commands as if the error did not occur.
Without the NOERR parameter, an error causes DiskPart to exit
with an error code.
If no drive letter or mounted folder is specified, the next available drive
letter is assigned. If the drive letter or mounted folder is already in use,
an error is generated.
By using the ASSIGN command, you can change the drive letter associated
with a removable drive.
You cannot assign drive letters to boot volumes or
volumes that contain the paging file. In addition, you cannot assign
a drive letter to an Original Equipment Manufacturer (OEM) partition
unless booted to Windows PE, or any GUID Partition Table (GPT) partition
other than a basic data partition, an ESP partition or a recovery
partition.
A volume must be selected for this operation to succeed.
Example:
ASSIGN LETTER=D
.
Language=Russian
<Add ASSIGN command help text here>
Assigns a drive letter or mounted folder pathname to the volume with focus.
Syntax: ASSIGN [LETTER=<D> | MOUNT=<PATH>] [NOERR]
LETTER=<D> The drive letter to assign to the volume.
MOUNT=<PATH>
The mounted folder pathname to assign to the volume.
NOERR For scripting only. When an error is encountered, DiskPart
continues to process commands as if the error did not occur.
Without the NOERR parameter, an error causes DiskPart to exit
with an error code.
If no drive letter or mounted folder is specified, the next available drive
letter is assigned. If the drive letter or mounted folder is already in use,
an error is generated.
By using the ASSIGN command, you can change the drive letter associated
with a removable drive.
You cannot assign drive letters to boot volumes or
volumes that contain the paging file. In addition, you cannot assign
a drive letter to an Original Equipment Manufacturer (OEM) partition
unless booted to Windows PE, or any GUID Partition Table (GPT) partition
other than a basic data partition, an ESP partition or a recovery
partition.
A volume must be selected for this operation to succeed.
Example:
ASSIGN LETTER=D
.
Language=Albanian
<Add ASSIGN command help text here>
Assigns a drive letter or mounted folder pathname to the volume with focus.
Syntax: ASSIGN [LETTER=<D> | MOUNT=<PATH>] [NOERR]
LETTER=<D> The drive letter to assign to the volume.
MOUNT=<PATH>
The mounted folder pathname to assign to the volume.
NOERR For scripting only. When an error is encountered, DiskPart
continues to process commands as if the error did not occur.
Without the NOERR parameter, an error causes DiskPart to exit
with an error code.
If no drive letter or mounted folder is specified, the next available drive
letter is assigned. If the drive letter or mounted folder is already in use,
an error is generated.
By using the ASSIGN command, you can change the drive letter associated
with a removable drive.
You cannot assign drive letters to boot volumes or
volumes that contain the paging file. In addition, you cannot assign
a drive letter to an Original Equipment Manufacturer (OEM) partition
unless booted to Windows PE, or any GUID Partition Table (GPT) partition
other than a basic data partition, an ESP partition or a recovery
partition.
A volume must be selected for this operation to succeed.
Example:
ASSIGN LETTER=D
.
Language=Turkish
<Add ASSIGN command help text here>
Assigns a drive letter or mounted folder pathname to the volume with focus.
Syntax: ASSIGN [LETTER=<D> | MOUNT=<PATH>] [NOERR]
LETTER=<D> The drive letter to assign to the volume.
MOUNT=<PATH>
The mounted folder pathname to assign to the volume.
NOERR For scripting only. When an error is encountered, DiskPart
continues to process commands as if the error did not occur.
Without the NOERR parameter, an error causes DiskPart to exit
with an error code.
If no drive letter or mounted folder is specified, the next available drive
letter is assigned. If the drive letter or mounted folder is already in use,
an error is generated.
By using the ASSIGN command, you can change the drive letter associated
with a removable drive.
You cannot assign drive letters to boot volumes or
volumes that contain the paging file. In addition, you cannot assign
a drive letter to an Original Equipment Manufacturer (OEM) partition
unless booted to Windows PE, or any GUID Partition Table (GPT) partition
other than a basic data partition, an ESP partition or a recovery
partition.
A volume must be selected for this operation to succeed.
Example:
ASSIGN LETTER=D
.
Language=Chinese
<Add ASSIGN command help text here>
Assigns a drive letter or mounted folder pathname to the volume with focus.
Syntax: ASSIGN [LETTER=<D> | MOUNT=<PATH>] [NOERR]
LETTER=<D> The drive letter to assign to the volume.
MOUNT=<PATH>
The mounted folder pathname to assign to the volume.
NOERR For scripting only. When an error is encountered, DiskPart
continues to process commands as if the error did not occur.
Without the NOERR parameter, an error causes DiskPart to exit
with an error code.
If no drive letter or mounted folder is specified, the next available drive
letter is assigned. If the drive letter or mounted folder is already in use,
an error is generated.
By using the ASSIGN command, you can change the drive letter associated
with a removable drive.
You cannot assign drive letters to boot volumes or
volumes that contain the paging file. In addition, you cannot assign
a drive letter to an Original Equipment Manufacturer (OEM) partition
unless booted to Windows PE, or any GUID Partition Table (GPT) partition
other than a basic data partition, an ESP partition or a recovery
partition.
A volume must be selected for this operation to succeed.
Example:
ASSIGN LETTER=D
.
Language=Taiwanese
<Add ASSIGN command help text here>
Assigns a drive letter or mounted folder pathname to the volume with focus.
Syntax: ASSIGN [LETTER=<D> | MOUNT=<PATH>] [NOERR]
LETTER=<D> The drive letter to assign to the volume.
MOUNT=<PATH>
The mounted folder pathname to assign to the volume.
NOERR For scripting only. When an error is encountered, DiskPart
continues to process commands as if the error did not occur.
Without the NOERR parameter, an error causes DiskPart to exit
with an error code.
If no drive letter or mounted folder is specified, the next available drive
letter is assigned. If the drive letter or mounted folder is already in use,
an error is generated.
By using the ASSIGN command, you can change the drive letter associated
with a removable drive.
You cannot assign drive letters to boot volumes or
volumes that contain the paging file. In addition, you cannot assign
a drive letter to an Original Equipment Manufacturer (OEM) partition
unless booted to Windows PE, or any GUID Partition Table (GPT) partition
other than a basic data partition, an ESP partition or a recovery
partition.
A volume must be selected for this operation to succeed.
Example:
ASSIGN LETTER=D
.
+12
View File
@@ -15,6 +15,7 @@ Usage: DISKPART [/S filename] [/T timeout] [/?]\n\n\
IDS_APP_PROMPT "DISKPART> "
END
/* ACTIVE command strings */
STRINGTABLE
BEGIN
IDS_ACTIVE_FAIL "\nDie Partition konnte nicht als aktiv markiert werden.\nVergewissern Sie sich, dass diese Partition gültig ist.\n"
@@ -23,6 +24,17 @@ BEGIN
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
END
/* ASSIGN command strings */
STRINGTABLE
BEGIN
IDS_ASSIGN_FAIL "\nEs konnte kein Laufwerksbuchstabe oder Bereitstellungspunkt zugewiesen werden.\nVergewissern Sie sich, dass der Laufwerksbuchstabe oder der Bereitstellungspunkt gültig ist.\n"
IDS_ASSIGN_SUCCESS "\nDer Laufwerksbuchstabe oder der Bereitstellungspunkt wurde zugewiesen.\n"
IDS_ASSIGN_ALREADY_ASSIGNED "\nDer angegebene Buchstabe wurde diesem Laufwerk bereits zugewiesen.\n"
IDS_ASSIGN_INVALID_LETTER "\nDer angegebene Laufwerksbuchstabe ist kein gültiger Volumebuchstabe.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nEs ist kein freier Laufwerksbuchstabe vorhanden, der diesem Volume zugewiesen werden kann.\nGeben Sie einen Laufwerksbuchstaben frei, und wiederholen Sie den Vorgang.\n"
END
/* AUTOMOUNT command strings */
STRINGTABLE
BEGIN
IDS_AUTOMOUNT_ENABLED "\nDie automatische Bereitstellung von neuen Volumes ist aktiviert.\n"
+12
View File
@@ -15,6 +15,7 @@ Usage: DISKPART [/S filename] [/T timeout] [/?]\n\n\
IDS_APP_PROMPT "DISKPART> "
END
/* ACTIVE command strings */
STRINGTABLE
BEGIN
IDS_ACTIVE_FAIL "\nDiskPart was unable to mark the partition active.\nMake sure the partition is valid.\n"
@@ -23,6 +24,17 @@ BEGIN
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
END
/* ASSIGN command strings */
STRINGTABLE
BEGIN
IDS_ASSIGN_FAIL "\nDiskPart could not assign the drive letter or mount point.\nMake sure the drive letter or mount point is valid.\n"
IDS_ASSIGN_SUCCESS "\nDiskPart successfully assigned the drive letter or mount point.\n"
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
END
/* AUTOMOUNT command strings */
STRINGTABLE
BEGIN
IDS_AUTOMOUNT_ENABLED "\nAutomatic mounting of new volumes enabled.\n"
+12
View File
@@ -22,6 +22,7 @@ Usage: DISKPART [/S filename] [/T timeout] [/?]\n\n\
IDS_APP_PROMPT "DISKPART> "
END
/* ACTIVE command strings */
STRINGTABLE
BEGIN
IDS_ACTIVE_FAIL "\nDiskPart non ha potuto segnare la partizione come attiva.\nAssicurarsi che la partizione sia valida.\n"
@@ -30,6 +31,17 @@ BEGIN
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
END
/* ASSIGN command strings */
STRINGTABLE
BEGIN
IDS_ASSIGN_FAIL "\nDiskPart could not assign the drive letter or mount point.\nMake sure the drive letter or mount point is valid.\n"
IDS_ASSIGN_SUCCESS "\nDiskPart successfully assigned the drive letter or mount point.\n"
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
END
/* AUTOMOUNT command strings */
STRINGTABLE
BEGIN
IDS_AUTOMOUNT_ENABLED "\nAutomatic mounting of new volumes enabled.\n"
+12
View File
@@ -15,6 +15,7 @@ Sposób użycia: DISKPART [/S nazwa_pliku] [/T limit_czasu] [/?]\n\n\
IDS_APP_PROMPT "DISKPART> "
END
/* ACTIVE command strings */
STRINGTABLE
BEGIN
IDS_ACTIVE_FAIL "\nDiskPart nie mógł oznaczyć partycji jako aktywnej.\nUpewnij się, że partycja jest prawidłowa.\n"
@@ -23,6 +24,17 @@ BEGIN
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
END
/* ASSIGN command strings */
STRINGTABLE
BEGIN
IDS_ASSIGN_FAIL "\nDiskPart could not assign the drive letter or mount point.\nMake sure the drive letter or mount point is valid.\n"
IDS_ASSIGN_SUCCESS "\nDiskPart successfully assigned the drive letter or mount point.\n"
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
END
/* AUTOMOUNT command strings */
STRINGTABLE
BEGIN
IDS_AUTOMOUNT_ENABLED "\nAutomatic mounting of new volumes enabled.\n"
+12
View File
@@ -17,6 +17,7 @@ Usage: DISKPART [/S filename] [/T timeout] [/?]\n\n\
IDS_APP_PROMPT "DISKPART> "
END
/* ACTIVE command strings */
STRINGTABLE
BEGIN
IDS_ACTIVE_FAIL "\nDiskPart was unable to mark the partition active.\nMake sure the partition is valid.\n"
@@ -25,6 +26,17 @@ BEGIN
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
END
/* ASSIGN command strings */
STRINGTABLE
BEGIN
IDS_ASSIGN_FAIL "\nDiskPart could not assign the drive letter or mount point.\nMake sure the drive letter or mount point is valid.\n"
IDS_ASSIGN_SUCCESS "\nDiskPart successfully assigned the drive letter or mount point.\n"
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
END
/* AUTOMOUNT command strings */
STRINGTABLE
BEGIN
IDS_AUTOMOUNT_ENABLED "\nAutomatic mounting of new volumes enabled.\n"
+12
View File
@@ -23,6 +23,7 @@ Utilizare: DISKPART [/S numefișier] [/T timplimită] [/?]\n\n\
IDS_APP_PROMPT "DISKPART> "
END
/* ACTIVE command strings */
STRINGTABLE
BEGIN
IDS_ACTIVE_FAIL "\nDiskpart nu a reușit să marcheze partiția activă.\nAsigurați-vă că partiția este validă.\n"
@@ -31,6 +32,17 @@ BEGIN
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
END
/* ASSIGN command strings */
STRINGTABLE
BEGIN
IDS_ASSIGN_FAIL "\nDiskPart could not assign the drive letter or mount point.\nMake sure the drive letter or mount point is valid.\n"
IDS_ASSIGN_SUCCESS "\nDiskPart successfully assigned the drive letter or mount point.\n"
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
END
/* AUTOMOUNT command strings */
STRINGTABLE
BEGIN
IDS_AUTOMOUNT_ENABLED "\nAutomatic mounting of new volumes enabled.\n"
+12
View File
@@ -17,6 +17,7 @@ BEGIN
IDS_APP_PROMPT "DISKPART> "
END
/* ACTIVE command strings */
STRINGTABLE
BEGIN
IDS_ACTIVE_FAIL "\nDiskPart was unable to mark the partition active.\nMake sure the partition is valid.\n"
@@ -25,6 +26,17 @@ BEGIN
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
END
/* ASSIGN command strings */
STRINGTABLE
BEGIN
IDS_ASSIGN_FAIL "\nDiskPart could not assign the drive letter or mount point.\nMake sure the drive letter or mount point is valid.\n"
IDS_ASSIGN_SUCCESS "\nDiskPart successfully assigned the drive letter or mount point.\n"
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
END
/* AUTOMOUNT command strings */
STRINGTABLE
BEGIN
IDS_AUTOMOUNT_ENABLED "\nAutomatic mounting of new volumes enabled.\n"
+12
View File
@@ -19,6 +19,7 @@ Usage: DISKPART [/S filename] [/T timeout] [/?]\n\n\
IDS_APP_PROMPT, "DISKPART> "
END
/* ACTIVE command strings */
STRINGTABLE
BEGIN
IDS_ACTIVE_FAIL "\nDiskPart was unable to mark the partition active.\nMake sure the partition is valid.\n"
@@ -27,6 +28,17 @@ BEGIN
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
END
/* ASSIGN command strings */
STRINGTABLE
BEGIN
IDS_ASSIGN_FAIL "\nDiskPart could not assign the drive letter or mount point.\nMake sure the drive letter or mount point is valid.\n"
IDS_ASSIGN_SUCCESS "\nDiskPart successfully assigned the drive letter or mount point.\n"
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
END
/* AUTOMOUNT command strings */
STRINGTABLE
BEGIN
IDS_AUTOMOUNT_ENABLED "\nAutomatic mounting of new volumes enabled.\n"
+12
View File
@@ -25,6 +25,7 @@ Kullanım: DISKPART [/S dosya adı] [/T zaman aşımı] [/?]\n\n\
IDS_APP_PROMPT "DISKPART> "
END
/* ACTIVE command strings */
STRINGTABLE
BEGIN
IDS_ACTIVE_FAIL "\nDiskPart, bölümü etkin olarak işaretleyemedi.\nBölümün geçerli olduğundan emin olun.\n"
@@ -33,6 +34,17 @@ BEGIN
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
END
/* ASSIGN command strings */
STRINGTABLE
BEGIN
IDS_ASSIGN_FAIL "\nDiskPart could not assign the drive letter or mount point.\nMake sure the drive letter or mount point is valid.\n"
IDS_ASSIGN_SUCCESS "\nDiskPart successfully assigned the drive letter or mount point.\n"
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
END
/* AUTOMOUNT command strings */
STRINGTABLE
BEGIN
IDS_AUTOMOUNT_ENABLED "\nAutomatic mounting of new volumes enabled.\n"
+12
View File
@@ -24,6 +24,7 @@ Usage: DISKPART [/S filename] [/T timeout] [/?]\n\n\
IDS_APP_PROMPT "DISKPART> "
END
/* ACTIVE command strings */
STRINGTABLE
BEGIN
IDS_ACTIVE_FAIL "\nDiskPart was unable to mark the partition active.\nMake sure the partition is valid.\n"
@@ -32,6 +33,17 @@ BEGIN
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
END
/* ASSIGN command strings */
STRINGTABLE
BEGIN
IDS_ASSIGN_FAIL "\nDiskPart could not assign the drive letter or mount point.\nMake sure the drive letter or mount point is valid.\n"
IDS_ASSIGN_SUCCESS "\nDiskPart successfully assigned the drive letter or mount point.\n"
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
END
/* AUTOMOUNT command strings */
STRINGTABLE
BEGIN
IDS_AUTOMOUNT_ENABLED "\nAutomatic mounting of new volumes enabled.\n"
+12
View File
@@ -24,6 +24,7 @@ Usage: DISKPART [/S 檔名] [/T 逾時] [/?]\n\n\
IDS_APP_PROMPT "DISKPART> "
END
/* ACTIVE command strings */
STRINGTABLE
BEGIN
IDS_ACTIVE_FAIL "\nDiskPart 無法把標記磁碟分割為使用中。\n請確認磁碟分割是有效的。\n"
@@ -32,6 +33,17 @@ BEGIN
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
END
/* ASSIGN command strings */
STRINGTABLE
BEGIN
IDS_ASSIGN_FAIL "\nDiskPart could not assign the drive letter or mount point.\nMake sure the drive letter or mount point is valid.\n"
IDS_ASSIGN_SUCCESS "\nDiskPart successfully assigned the drive letter or mount point.\n"
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
END
/* AUTOMOUNT command strings */
STRINGTABLE
BEGIN
IDS_AUTOMOUNT_ENABLED "\nAutomatic mounting of new volumes enabled.\n"
+24 -7
View File
@@ -18,8 +18,8 @@ remove_main(
{
WCHAR szMountPoint[4];
PWSTR pszSuffix = NULL;
PWSTR pszLetter = NULL;
INT i;
WCHAR DriveLetter = UNICODE_NULL;
INT i, nExclusive = 0;
BOOL bResult;
DPRINT("remove_main()\n");
@@ -52,9 +52,10 @@ remove_main(
{
if (HasPrefix(argv[i], L"letter=", &pszSuffix))
{
if ((wcslen(pszSuffix) == 1) && (iswalpha(*pszSuffix)))
if (wcslen(pszSuffix) == 1)
{
pszLetter = pszSuffix;
DriveLetter = towupper(*pszSuffix);
nExclusive++;
}
else
{
@@ -66,10 +67,12 @@ remove_main(
{
DPRINT("Mount\n", pszSuffix);
ConPuts(StdOut, L"The MOUNT option is not supported yet!\n");
nExclusive++;
}
else if (_wcsicmp(argv[i], L"all") == 0)
{
ConPuts(StdOut, L"The ALL option is not supported yet!\n");
nExclusive++;
}
else if (_wcsicmp(argv[i], L"dismount") == 0)
{
@@ -86,19 +89,33 @@ remove_main(
}
}
if (nExclusive > 1)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
}
DPRINT("VolumeName: %S\n", CurrentVolume->VolumeName);
DPRINT("DeviceName: %S\n", CurrentVolume->DeviceName);
DPRINT("DriveLetter: %C\n", CurrentVolume->DriveLetter);
if (pszLetter)
if (DriveLetter != UNICODE_NULL)
{
if (towupper(pszLetter[0]) != CurrentVolume->DriveLetter)
DPRINT1("DriveLetter: %C\n", DriveLetter);
if ((DriveLetter < L'C') || (DriveLetter > L'Z'))
{
ConResPuts(StdOut, IDS_ASSIGN_INVALID_LETTER);
return TRUE;
}
if (DriveLetter != CurrentVolume->DriveLetter)
{
ConResPuts(StdOut, IDS_REMOVE_WRONG_LETTER);
return TRUE;
}
szMountPoint[0] = towupper(pszLetter[0]);
szMountPoint[0] = DriveLetter;
szMountPoint[1] = L':';
szMountPoint[2] = L'\\';
szMountPoint[3] = UNICODE_NULL;
+9 -3
View File
@@ -27,9 +27,15 @@
#define IDS_AUTOMOUNT_DISABLED 1011
#define IDS_AUTOMOUNT_SCRUBBED 1012
#define IDS_CLEAN_FAIL 1020
#define IDS_CLEAN_SUCCESS 1021
#define IDS_CLEAN_SYSTEM 1022
#define IDS_ASSIGN_FAIL 1020
#define IDS_ASSIGN_SUCCESS 1021
#define IDS_ASSIGN_ALREADY_ASSIGNED 1022
#define IDS_ASSIGN_INVALID_LETTER 1023
#define IDS_ASSIGN_NO_MORE_LETTER 1024
#define IDS_CLEAN_FAIL 1030
#define IDS_CLEAN_SUCCESS 1031
#define IDS_CLEAN_SYSTEM 1032
#define IDS_CONVERT_GPT_ALREADY 1040
#define IDS_CONVERT_GPT_NOT_EMPTY 1041