TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Marc'Antonio Alessi on February 03, 2023, 02:55:15 AM
-
I'm looking for a function that gives the same result as dos_serialno, the functions I report below (sorry if I didn't report all the credits)
[/size]get three different results...
[/size]"BCA30E72" -1130164622 "50026B775203E442"
(dos_serialno "C:") => "BCA30E72"
(#Asmi_Get_Drive_Serial "c:") => -1130164622
(UsbDriveSerialNumber) => ((("C:" -1130164622) ("G:" 428019990) ("H:" 943522054) ("Z:" -693829664)) nil)
(VxGetDriveInfos "C:") => (2.15739e+008 4.28575e+007 2 "NTFS" -1130164622 "" "OS")
(gthardware:generateid) => ("-1130164622" "ASUS01" "User1")
(HDSerial) => "50026B775203E442"
; drive type 1 is a usb 2 hard disk
(defun UsbDriveSerialNumber ( / fso HrdDsk UsbDsk)
(setq fso (vlax-create-object "Scripting.FileSystemObject"))
(vlax-for d (vlax-get fso 'Drives)
(cond
( (= (Vlax-get d 'DriveType) 1)
(setq UsbDsk (cons (list (vla-get-path d) (vla-get-SerialNumber d)) UsbDsk))
)
( (= (Vlax-get d 'DriveType) 2)
(setq HrdDsk (cons (list (vla-get-path d) (vla-get-SerialNumber d)) HrdDsk))
)
; ( T (print d) )
)
)
(vlax-release-object fso)
(list (reverse HrdDsk) (reverse UsbDsk))
)
;;; PART OF 'ASMILIB' LIBRUARY *
;;; Created: 07.10.2007 *
;;; Last modyfied: 07.10.2007 *
;;; © Alexanders Smirnovs (ASMI) *
(defun #Asmi_Get_Drive_Serial(Path / fsObj hSn abPth cDrv)
(vl-load-com)
(if
(and
(setq fsObj(vlax-create-object "Scripting.FileSystemObject"))
(not
(vl-catch-all-error-p
(setq abPth(vl-catch-all-apply 'vlax-invoke-method
(list fsObj 'GetAbsolutePathName Path))
); end setq
); end vl-catch-all-error-p
); end not
); end and
(progn
(setq cDrv(vlax-invoke-method fsObj 'GetDrive
(vlax-invoke-method fsObj 'GetDriveName abPth
); end vlax-invoke-method
);end vlax-invoke-method
); end setq
(if
(vl-catch-all-error-p
(setq hSn(vl-catch-all-apply 'vlax-get-property
(list cDrv 'SerialNumber))))
(progn
(vlax-release-object cDrv)
(setq hSn nil)
); end progn
); end if
(vlax-release-object fsObj)
); end progn
); end if
hSn
); end of #Asmi_Get_Drive_Serial
(defun HDSerial ( / wmi srv drv ser )
(vl-catch-all-apply
(function
(lambda ( )
(if
(setq wmi (vlax-create-object "WbemScripting.SWbemLocator")
srv (vlax-invoke wmi 'connectserver nil nil nil nil nil nil nil nil)
drv (vlax-invoke srv 'execquery "Select SerialNumber from Win32_DiskDrive")
)
(vlax-for item drv
(vlax-for prop (vlax-get item 'Properties_)
(if (eq "SERIALNUMBER" (strcase (vlax-get prop 'name)))
(setq ser (vl-string-trim " " (vlax-get prop 'value)))
)
)
)
)
)
)
)
(if drv (vlax-release-object drv))
(if srv (vlax-release-object srv))
(if wmi (vlax-release-object wmi))
ser
)
(DEFUN gthardware:generateid (/ filesystemobject drives n serial wscript pcname pcuser)
(SETQ serial 0
pcname ""
pcuser ""
)
(COND ((SETQ wscript (VLAX-CREATE-OBJECT "WScript.Network"))
(SETQ pcname (VLAX-GET-PROPERTY wscript "ComputerName") ; Computer Name
pcuser (VLAX-GET-PROPERTY wscript "UserName") ; UserName
)
(VLAX-RELEASE-OBJECT wscript)
;; Obtain the first Hard drive serial number
(COND ((SETQ filesystemobject (VLAX-CREATE-OBJECT "Scripting.FilesystemObject"))
;; access the Drives collection
(SETQ drives (VLAX-GET-PROPERTY filesystemobject 'drives))
;; Check each drive for a fixed drive. When the first drive is found, exit.
(VL-CATCH-ALL-APPLY
'(LAMBDA ()
(VLAX-FOR n drives
;;If there drive is a fixed drive, get the serial and exit
(IF (= (VLAX-GET-PROPERTY n 'drivetype) 2)
(PROGN
(SETQ serial (VLAX-GET-PROPERTY n 'serialnumber))
(EXIT)
)
)
)
)
)
;; Release the vla objects
(VLAX-RELEASE-OBJECT drives)
(VLAX-RELEASE-OBJECT filesystemobject)
)
)
)
)
(list (ITOA serial) pcname pcuser)
)
; Copyright: ©2001 MENZI ENGINEERING GmbH, Switzerland
;
(defun VxGetDriveInfos (Drv / DrvObj FilSys RetVal)
(vl-load-com)
(setq FilSys (vlax-create-object "Scripting.FileSystemObject")
RetVal (cond
((= (vlax-invoke FilSys 'DriveExists Drv) 0) 0)
((setq DrvObj (vlax-invoke FilSys 'GetDrive Drv))
(cond
((= (vlax-get DrvObj 'IsReady) 0) -1)
((list
(/ (vlax-get DrvObj 'TotalSize) 1000.0)
(/ (vlax-get DrvObj 'FreeSpace) 1000.0)
(vlax-get DrvObj 'DriveType)
(vlax-get DrvObj 'FileSystem)
(vlax-get DrvObj 'SerialNumber)
(vlax-get DrvObj 'ShareName)
(vlax-get DrvObj 'VolumeName)
)
)
)
)
)
)
(if DrvObj (vlax-release-object DrvObj))
(vlax-release-object FilSys)
RetVal
)
-
Why you need, the serial number of-HDD?
You, do insert more crashes inside AutoCad?
Perhaps you block the programs.fas, forced to operating system win11?
:thinking:
-
works on win7
not sure about others
(defun vk_GetWbem (NameSpace Class Props / LocatorObj ServiceObj ObjectSetObj OutList)
(and (setq LocatorObj (vlax-create-object "WbemScripting.SWbemLocator"))
(setq ServiceObj (vlax-invoke-method LocatorObj 'ConnectServer "." NameSpace nil nil nil nil nil nil))
(setq ObjectSetObj (vlax-invoke-method ServiceObj 'ExecQuery (strcat "SELECT * FROM " Class) nil nil nil))
(vlax-for Obj ObjectSetObj
(setq OutList (cons (mapcar (function (lambda (p) (cons p (vlax-get Obj p)))) Props)
OutList
)
)
)
)
(vk_ReleaseObjects (list ObjectSetObj ServiceObj LocatorObj))
(reverse OutList)
)
(defun vk_GetHDDID (/)
(mapcar 'list
(mapcar 'cdar (vk_GetWbem "root\\cimv2" "Win32_DiskDrive" (list "Model")))
(mapcar 'cdar (vk_GetWbem "root\\cimv2" "Win32_PhysicalMedia" (list "SerialNumber")))
)
)
-
works on win7
not sure about others
...
Thanks VovKa :
; errore: no function definition: VK_RELEASEOBJECTS
-
Thanks VovKa :
; errore: no function definition: VK_RELEASEOBJECTS
nothing special, just substitute it with (mapcar 'vlax-release-object ... )
-
Thanks VovKa :
; errore: no function definition: VK_RELEASEOBJECTS
nothing special, just substitute it with (mapcar 'vlax-release-object ... )
Thanks again,
(vk_GetHDDID) => (("RSH USB Device" "00A123456789 ") ("KINGSTON SV300S37A240G" "50026B775203E442"))
sorry again for my ignorance but with
(dos_serialno "C:") => "BCA30E72"
why do I have a different result?
-
why do I have a different result?
as i mentioned earlier, my code works on win7. that's the operating system i'm using
i removed my pc's cover and checked the returned serial against hdd's sticker, they match
and i've also found a comment in my lisp file concerning this function
;;;Win XP/2003 only, no SATA
so it's windows version dependent
-
are you looking for the volume label? XXXX-XXXX
"Select VolumeSerialNumber from Win32_LogicalDisk"
-
(http://)
-
(dos_serialno "C:") used to return the volume serial
if you go to the command prompt c:\, type dir, you should see it at the top
this serial changes when you format the volume, this is not to be confused with a hardware serial number
-
... i removed my pc's cover and checked the returned serial against hdd's sticker, they match ...
Grazie..., thanks for your time. :)
-
I have modified the function HDSerial posted:
(defun ALE__Files_VolSerialLogNo ( / wmi srv drv ser)
(vl-catch-all-apply
(function
(lambda ( )
(if
(setq wmi (vlax-create-object "WbemScripting.SWbemLocator")
srv (vlax-invoke wmi 'connectserver nil nil nil nil nil nil nil nil)
drv (vlax-invoke srv 'execquery "Select VolumeSerialNumber from Win32_LogicalDisk")
)
(vlax-for item drv
(vlax-for prop (vlax-get item 'Properties_)
(if (eq "VOLUMESERIALNUMBER" (strcase (vlax-get prop 'name)))
(setq ser (vl-string-trim " " (vlax-get prop 'value)))
)
)
)
)
)
)
)
(foreach obj (list drv srv wmi) (and obj (vlax-release-object obj)))
ser
)
(ALE__Files_VolSerialLogNo) => "BCA30E72"
(dos_serialno "C:") => "BCA30E72"
Thanks Daniel and BIGAL :)
-
user beware !
perhaps, or perhaps not :
-
New version...
(defun ALE_Files_VolSerialLogNos ( / wmi srv drv ser did vsn prp)
(vl-catch-all-apply
(function
(lambda ( )
(if
(setq wmi (vlax-create-object "WbemScripting.SWbemLocator")
srv (vlax-invoke wmi 'connectserver nil nil nil nil nil nil nil nil)
drv (vlax-invoke srv 'execquery "Select VolumeSerialNumber from Win32_LogicalDisk")
)
(vlax-for item drv
(vlax-for prop (vlax-get item 'Properties_)
(setq prp (strcase (vlax-get prop 'name)))
(cond
( (eq "DEVICEID" prp) (setq did (vlax-get prop 'value)) )
( (eq "VOLUMESERIALNUMBER" prp) (setq vsn (vlax-get prop 'value)) )
)
); (print prp) (princ " ") (prin1 did) (princ " ") (prin1 vsn)
(and did vsn (setq ser (cons (cons did vsn) ser)))
)
)
)
)
)
(foreach obj (list drv srv wmi) (and obj (vlax-release-object obj)))
ser
)
(ALE_Files_VolSerialLogNos) => (("Z:" . "D6A4FFE0") ("H:" . "383D0106") ("G:" . "19831116") ("C:" . "BCA30E72"))
-
User beware !
Perhaps or perhaps not :
-
User beware !
Perhaps or perhaps not :
does the new version have the same problems?
-
do you plan to use this serial in some protection scheme?
-
do you plan to use this serial in some protection scheme?
Right, it can be changed pretty easily, I know a friend who did that a couple times
-
do you plan to use this serial in some protection scheme?
yes, but I don't have any particular ultra-security needs :D
-
Can help to edit the code of Marc'Antonio Alessi, so that it only returns the serial number of the system drive, the drive where the operating system was installed ?
-
Just a comment, for protection use fas etc as 1st level, ok there is a DOS way to add to all your lisps in 1 go the security check, yes have used it often, so write the checkdisk id as a seperate lisp, using bat file etc copy ser.lsp+lisp1.lsp c:\compilelisps\lisp1.lsp, will have to find again, but security added and compiled 130 lisps in one go. I use (EXIT) in the check as that aborts the current lisp.
Do you know who to make bulk fas files etc. Can use lisp.
Post if want more information.
Personally yes had a phone call software not working, final result was trying to give software to some one else, security worked.
-
Hi Bigal, appreciate your reply, but I do not really understand what you meant.
Could you elaborate more ?
For me, I use VLIDE, make a project, compiles my lisps into fas.
Then use Make Application to compile all fas into VLX.
Getting hard disk sn is part of security check, make sure user cannot simply copy my VLX and use in other unauthorised pc.
Do you think VLX can be decoded ? Saw someone said can.
Any suggestion, links to build a better security is welcomed.
-
Who made compiler, for sure made and decompiler, or knows how decompile works...
But that one for sure isn't interested in viewing our poor coding stuff...
-
haha, you are right, just to protect from non-expert.
:roll:
-
go for mac-address
-
Thank you very much !