A few years ago, I wrote an article explaining how to change the volume serial number.
This program does not work properly now under Windows Vista or Windows 7 unless executed as administrator. Following many suggestions, I updated the tool to support the latest Windows version.
Please note that after you change the serial number you may need to reboot the PC for the settings to take effect.
Download the tool from here: http://rapidshare.com/files/431997166/VolumeSerial_1.3.zip
UPDATE: If you’re using Windows Vista+ make sure you run this program as an administrator.
Mike said
Are you willing to share the new codes that cover the windows 7 as you did a few years ago?
lallousx86 said
The same code should work on Windows 7. Just run the tool as admin. Please try and let me know.
As long as you have FAT or NTFS it should work.
Ninel said
Hi Elias,
Great tool!
) to write a tool that extracts the volume serial number and the volume label without changing anything from command line.
(
I used your code
Windows has the command “VOL” (part of cmd.exe) but the problem comes when a user has its OS in a Non-English language and VOL give the output messages in that language, being hard to extract correctly the required data with a script. I still can use GAWK for that, but for sure in Japanese/Russian will give some errors
Thank you very much! (see sourceforge project winlocate v0.1.6)
//################ CODE #####################
#include
#include
#include
#include
#include
#pragma warning(disable: 4996)
void GetDriveInfo(TCHAR Drive, int Exit_Code)
{
DWORD serialNumber, maxComponentLength, fsFlags;
TCHAR szFileSystem[24];
TCHAR szVolumeName[64];
TCHAR szRoot[4] = L”C:\\”;
szRoot[0] = (TCHAR)(Drive);
if (! GetVolumeInformation(szRoot, szVolumeName, sizeof(szVolumeName), &serialNumber, &maxComponentLength, &fsFlags, szFileSystem, sizeof(szFileSystem)))
{
fwprintf(stderr, L”%c: – Error: Failed to retrieve drive information!\n”, Drive);
if(Exit_Code) { exit(1); }
}
else
{
if(!wcslen(szVolumeName))
{
wcscpy(szVolumeName, L”Local Disk”);
}
wprintf(L”%c:\t%s\t%04X-%04X\t%s\n”, Drive, szFileSystem, serialNumber >> 16, serialNumber & 0xFFFF, szVolumeName);
}
}
void GetDrives(void)
{
DWORD iLogicalDrives = ::GetLogicalDrives();
for (int i=0; i<26; i++)
{
if (((1 << i) & iLogicalDrives) != 0)
{
GetDriveInfo((TCHAR)(i+'A'), 0); //printf("%c\n",i+'A'); /*for debug*/
}
}
}
void Error(char MSG[100])
{
printf("Listdrive – v2.0 – Ninel Piroi\n\nError: %s!\n\nUsage:\n 'Listdrive X:' – to display drive X: info\n 'Listdrive -A' – to display info for all drives\n", MSG);
exit(1);
}
int wmain(int argc, _TCHAR* argv[])
{
int result;
if(argc = 65) && ((int)argv[1][0] <= 90)))
{
Error("Incorrect drive argument leter, A-Z");
}
else
{
GetDriveInfo(argv[1][0], 1);
}
//printf("-%d-", (int)argv[1][0]); /*for debug*/
//wprintf(L"%s", argv[1]); /*for debug*/
//GetDriveInfo(L'D'); /*for debug*/
return 0;
}