Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8696459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:16:31+00:00 2026-06-13T01:16:31+00:00

I currently have a function that returns the hard drive serial of a virtual

  • 0

I currently have a function that returns the hard drive serial of a virtual machine using calls via WMI, which works great when run on an actual physical hard drive. However, when I run the function on a virtual machine with a virtual disk, the hard drive serial always comes back as the same series of 1’s and 0’s. I am trying to use this technique to identify a specific machine. Is there a more reliable way to retrieve some sort of identifier which identifies the hardware used in a (virtual) machine that will likely not change?

As a note, I have had the MAC Address given to me as a suggestion, but I do not want my software to break if the NIC it is bound to has to be replaced.

I am also concerned with what might return on a system hard drive which is configured via RAID, as this serial needs to be consistent with every call. I do not have a RAID configured system to test this on, however, so I am unsure of what will even be returned in the first place.

EDIT I have figured out a reliable way to lock our software to a virtual machine even if the serial number might not be unique, so the VM portion is no longer an issue. However, I still am unsure of how this might return on with certain RAID configurations, and as stated above, I do not have the luxury of a RAID configured machine to test on, much less several configurations to test. Any assistance on this is very much appreciated.

Here is the HD serial function:

string Win32_Class = string.Empty;
string Win32_Property = string.Empty;
string systemDrive = null;
try
{
    systemDrive = System.Environment.GetFolderPath(System.Environment.SpecialFolder.System).Substring(0, 2);
    Win32_Class = "Win32_LogicalDisk";
    using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(string.Format("SELECT * FROM {1} WHERE DeviceID='{0}'", systemDrive, Win32_Class)))
    {
        foreach (ManagementObject logicalDisk in searcher.Get())
        {
            Win32_Class = "Win32_DiskPartition";
            foreach (ManagementObject partition in logicalDisk.GetRelated(Win32_Class))
            {
                Win32_Class = "Win32_DiskDrive";
                foreach (ManagementObject diskDrive in partition.GetRelated(Win32_Class))
                {
                    Win32_Class = "Win32_PhysicalMedia";
                    foreach (ManagementObject diskMedia in diskDrive.GetRelated(Win32_Class))
                    {
                        Win32_Property = "SerialNumber";
                        mySystemDeviceSerial = diskMedia[Win32_Property].ToString().Trim();
                    }
                }
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:16:32+00:00Added an answer on June 13, 2026 at 1:16 am

    You could use the serial number of the ‘logical’ disk. This will change if the disk is repartitioned. If one drive of a redundant RAID setup is changed it won’t change. This is something stored at the block level so it won’t matter what the actual storage setup is.

    You want the VolumeSerialNumber property of a Win32_LogicalDisk for the installation volume.

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394173(v=vs.85).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a function that will create X tasks of a function based
I currently have a function that grabs the browser windows uri, parses out the
I currently have a Javascript function that uses a string to reference an object
I currently have a function written called saveWorkout that saves an NSMutableArray to another
I currently have a function that is meant to return T (templated function). So
So I have function that formats a date to coerce to given enum DateType{CURRENT,
I have a function that get the current weeknumber from the given date e.g.
On my program I have a function that checks for the current version of
I have the following function that deletes the LaTeX command surrounding the current cursor
I currently have this: function submit() { document.getElementById(lostpasswordform).click(); // Simulates button click document.lostpasswordform.submit(); //

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.