Get Drive Serial Number

Discussion in 'AutoCAD' started by Robert Good, Jun 24, 2004.

  1. Robert Good

    Robert Good Guest

    I have seen this question before, but I can't seem to find any answers.

    Is it possible to get the drive serial number (for protection / verification
    of written routines)

    (vla-get-property drive 'serialnumber) --which does not work for me--

    I have seen a lisp routine on
    http://www.menziengineering.ch/Downloads/Download.htm#22 but it requires
    additional installation of a scripting file named ScrRun.dll. I would like
    to avoid this and think this should be possible within visual lisp.

    any ideas?

    Robert Good.
     
    Robert Good, Jun 24, 2004
    #1
  2. Robert Good

    ECCAD Guest

    ECCAD, Jun 24, 2004
    #2
  3. An alternative method using native Autolisp;

    ; SERIAL.LSP - Routine to return the hard drive volume label.
    ; ==========
    ; suggested use ---> (setq SERIAL_NUM (SERIAL))
    ;
    (defun SERIAL (/ OLDECHO FILE NUM )
    (setq OLDECHO (getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    (command "_SHELL" "DIR C:\\ DIR > C:\\DIRLIST.TXT")
    (while (not (findfile "C:/DIRLIST.TXT")))
    (setq FILE (open "C:/DIRLIST.TXT" "r"))
    (setq NUM (read-line FILE))
    (setq NUM (read-line FILE))
    (close FILE)
    (while (not NUM))
    (command "_SHELL" "ERASE C:\\DIRLIST.TXT")
    (setvar "CMDECHO" OLDECHO)
    (princ NUM)
    )
     
    Richard-Willis, Jun 24, 2004
    #3
  4. Robert Good

    Robert Good Guest

    Thanks,
    I will get the doslib and put'er to work.

    Thanks Bob.
     
    Robert Good, Jun 24, 2004
    #4
  5. Robert Good

    cwanless Guest

    The serial number can also be found in the registry somewhere. I am not sure where though.

    Thanks Chad Wanelss
     
    cwanless, Jun 24, 2004
    #5
  6. Perhaps only with XP? Win2K here and I was
    unable to locate the serial number in the registry.
     
    Jason Piercey, Jun 24, 2004
    #6
  7. I have been trying to do this myself, but so far have not had any luck.
    There is a Windows class that can be used from VB (and therefore ActiveX and
    then VLisp (maybe)), but it only works on Windows XP. I have been trying ot
    find out if it can be used on other OS's but so far no luck. I have found
    someone that says he can get it on any OS without using this class, but he
    has not gotten back to me yet. The class is Win32_PhysicalMedia just in case
    you want to try it.
     
    Randy Sanders, Jun 24, 2004
    #7
  8. Does this return the HardDrive serial number from the firmware, or just the
    volume serial number? The volume serial number can easily be changed by the
    user.
     
    Randy Sanders, Jun 24, 2004
    #8
  9. This gives you the volume serial number and not the actual hard drive serial
    number. The user can easily change the volume serial number.
     
    Randy Sanders, Jun 24, 2004
    #9
  10. Robert Good

    ECCAD Guest

    That would be a good question for McNeel & Assoc's.
    I (think) it is just the volume serial number. But, this is good.
    If you 'start' your app, checking the Hard Drive SN, and the user decides to change it..your app would not fire. I think that's the point.

    Bob
     
    ECCAD, Jun 24, 2004
    #10
  11. Robert Good

    Steve Doman Guest

    With all due respect to Doslib, it's a wonderful utility. But beware
    that if you are using dos_serial number to get the hard drive serial
    number for copy protection, that your scheme might be easily cracked if
    someone knows at least one of the harddisk serial numbers that you
    application checks for.

    Say for example on a machine that is licensed to use your application,
    dos_serialno returns might return something like the following:

    (dos_serialno "C:") -> "3d575430"

    Know if someone knows a good hard disk serial number they could
    overwrite the dos_serialno function like this allow your application to run:

    (defun dos_serialno (x)
    (print "3d575430")
    (princ)
    )

    One way to deal with this issue is reload DosLib just before running a
    check on the serial number.

    Regards,
    Steve Doman
     
    Steve Doman, Jun 25, 2004
    #11
  12. Yes, but it is easily copied to another system, so it provides minimal copy
    protection. If I know an application used the volume serial number, I can
    copy the software to another system and set its volume serial number to be
    the same and the software will work fine. I have finally found out how to
    get the "true" serial number, but it is complex and in "C" only. I do not
    know enough about VB or VLisp to know if it can be translated to them, and
    kinda doubt it, since it relies on specific structures with specific byte
    alignment and has to do a lot of bit manipulation to get the serial number.
    I am also still testing it in all environments with limited permission users
    and such.
     
    Randy Sanders, Jun 25, 2004
    #12
  13. Even reloading doslib would not be a guarentee, since they could replace it
    with a different file named the same that loads the true doslib file and
    then redefines the function.
     
    Randy Sanders, Jun 25, 2004
    #13
  14. Robert Good

    Steve Doman Guest

    Randy,

    Good point. And alternative approach is to write your own function to
    get the hard disk serial number. I don't have any experience doing
    that, but I did read a tutorial by Stig Madsen at the link below, that
    tells how to use AutoLISP to access the Windows Script Host in order to
    get the hard disk serial number. I haven't tried this method yet, but
    it looks promising.

    http://www.afralisp.com/lisp/script1.htm

    Steve
     
    Steve Doman, Jun 26, 2004
    #14
  15. Robert Good

    Jürg Menzi Guest

    Hi Robert

    Visit my homepage -> Free Stuff and search for 'VxGetDriveInfos'...

    Cheers
     
    Jürg Menzi, Jun 26, 2004
    #15
  16. Robert Good

    Robert good Guest

    Juerg,
    your routine requires the use of the ScrRun.dll. Im guessing this is the windows scripting extension. How can you tell thru visual lisp that this program is running.
    also, if it is not running / installed can you do it thru lisp?
     
    Robert good, Jun 26, 2004
    #16
  17. Robert Good

    Jürg Menzi Guest

    Hi Robert

    Windows Script Components are part of the OS since Win2k/XP. If you're using
    WinNT4/Win9x you've to download Windows Script Runtime from:
    http://msdn.microsoft.com/scripting

    To check the availability of the components by Vlisp use following code:
    (defun VxCheckWsc ( / FilSys)
    (if (vl-catch-all-error-p
    (vl-catch-all-apply
    (function
    (lambda ()
    (setq FilSys (vlax-create-object "Scripting.FileSystemObject"))
    )
    )
    )
    )
    (alert "Windows Script Components not installed.")
    (or (vlax-release-object FilSys) T)
    )
    )
    Returns T if installed, else nil (and an error message)

    Installation can be done by the components setup wizard.

    Cheers
     
    Jürg Menzi, Jun 28, 2004
    #17
  18. Robert Good

    Robert Good Guest

    Great,

    Thanks Jurg.
     
    Robert Good, Jun 28, 2004
    #18
  19. Robert Good

    Jürg Menzi Guest

    Glad to help you...

    Cheers
     
    Jürg Menzi, Jun 28, 2004
    #19
  20. I ran a quick test and I am not sure what this is getting, but it is not the
    drive serial number. It is some variation of the volume serial number. If I
    run it with "c:" or "d:" I get different numbers, even though both those
    drives are partitions on the same physical drive. If it is some variation of
    the volume serial number it can be duplicated on another machine.
     
    Randy Sanders, Jun 28, 2004
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.