+ Reply to Thread
Results 1 to 14 of 14

Get Hard Drive Serial Number?

  1. #1
    Registered User
    Join Date
    03-13-2007
    Location
    Metro Atlanta
    Posts
    48

    Get Hard Drive Serial Number?

    I want to write a macro that will retrieve the user's hard drive serial number. I tried running the macro in the SerialNumber Property example in VB Help but all it did was open the Macro dialog box, then it wouldn't run again.

    I've seen several examples posted on the web but none work.

    Does anyone know how to really do this?

    Thanks.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486
    Not sure is this it??
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-13-2007
    Location
    Metro Atlanta
    Posts
    48
    That worked just fine. Thanks.
    Here is what I added:

    Sub SerialNumber()
    MyPath = Left("" & ActiveWorkbook.Path & "", 2)
    Dim oFSO As Object
    Dim drive As Object
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set drive = oFSO.GetDrive("" & MyPath & "")
    MsgBox drive.SerialNumber
    'ActiveSheet.Range("F11") = drive.SerialNumber
    Set oFSO = Nothing
    Set drive = Nothing
    'release memory

    End Sub

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Please wrap your code using by clicking on the # symbol in edit mode.
    Link below explains more

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Paul

    VBA Noob is not attaching his name to threads for any reason.

    As a moderator of this site VBA Noob's reply was directed to ern2ern to point out the ern2ern was not following the forum rules.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  6. #6
    Registered User
    Join Date
    12-19-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Get Hard Drive Serial Number?

    Dear ern2ern it is very nice and i was looking this from 2012 to day i am very thank full to you and added reputation also. now only one thing this code is popping up a window can you suggest a modified code which writes this in to some particular cells in excel like,

    the number must be written to

    A10 B20 C30 cell as soon i open the excel automatically

    please help me in this. thanks in advance

  7. #7
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Get Hard Drive Serial Number?

    @pcbpradeep

    Next time make your own thread.

    Please Login or Register  to view this content.
    Please click the * Add Reputation if this helps
    If solved remember to mark Thread as solved

    "I'm glad to help and this is not meant to sound smart, but either you have super-human vision to see all those controls cleared one by one with the code I posted, or your computer is really slow."

  8. #8
    Registered User
    Join Date
    12-19-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Get Hard Drive Serial Number?

    Dear Blokeman thank you for quick suggestion, but
    1.the code given is not working it is closing and no macro file names are appearing in excel to run.
    2.I just don't want to query only C drive, but the path where the file will be. the code from ern2ern is doing exactly what i want only difference is, it is popping up the serial and i want to write in to multiple cells.
    again sorry for posting in this thread.

  9. #9
    Registered User
    Join Date
    12-19-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Get Hard Drive Serial Number?

    Yes blokeman finally i got it i just clubbed both and it is working fine given reputation to you also. my actual question from 2012 is as in ling if you can help me on that also please check it once
    **http://www.excelbanter.com/showthread.php?p=1608158

    thank you again
    Last edited by pcbpradeep; 08-13-2014 at 10:12 AM.

  10. #10
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,626

    Re: Get Hard Drive Serial Number?

    @pcbpradeep,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ben Van Johnson

  11. #11
    Registered User
    Join Date
    05-12-2015
    Location
    LA
    MS-Off Ver
    2007, 2013
    Posts
    1

    Re: Get Hard Drive Serial Number?

    Hi.
    This is great code that works.
    I would like to know if this works with Mac...?
    I would like to somehow verify the Book is not a copy.
    So, I'm thinking to enter the serial number in the cell/sheet before giving, and match the number with the actual serial number obtaining with this code.
    I'm guessing that the Office's Product ID code may work as well.

    How can I do that with Mac?

    Thank you for your help!

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Get Hard Drive Serial Number?

    kumi, welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  13. #13
    Registered User
    Join Date
    01-03-2019
    Location
    Lima, Perù
    MS-Off Ver
    2010
    Posts
    1

    Re: Get Hard Drive Serial Number?

    Hi, i new in the forum. I learned how to use VBA on yt so i am not an expert using it, nevertheless i made a excel file that i`d like to sell to some people, but i dont want them to pirated it, so i was wondering if it is posible to created a macro that can identify hard disk serial number and request a password.

    i'd aprecciate your help!!

  14. #14
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,748

    Re: Get Hard Drive Serial Number?

    Quote Originally Posted by cristrios07 View Post
    Hi, i new in the forum. I learned how to use VBA on yt so i am not an expert using it, nevertheless i made a excel file that i`d like to sell to some people, but i dont want them to pirated it, so i was wondering if it is posible to created a macro that can identify hard disk serial number and request a password.

    i'd aprecciate your help!!
    cristrios07, welcome to the Forum! We don't allow new questions in somebody else's thread. Please start a new thread with your question.

    Please take the time to review our rules. There aren't many, and they are all important.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1