Jump to content

unique ID for System(PC)


 Share

Recommended Posts

Example:

$RunPID = Run(@ComSpec & " /c wmic csproduct get UUID", @SystemDir, @SW_HIDE, 0x2)

Dim $sRead

While 1
    $sRead &= StdoutRead($RunPID)
    If @error Then ExitLoop
WEnd

$sUUID = StringRegExp($sRead, "[\d-]+", 1)
If @error Then Exit

$sUUID = $sUUID[0]
MsgBox(64, "Computer Universally Unique Identifer", $sUUID)

:)

What regular expression is that? What it means?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

My UUID is "2".

Is that my unique ID of the PC?

[list][font="Century Gothic"]If nothing is certain, everything is possible.[/font][/list][font="Century Gothic"]Experience is something you get, just after you need it.[/font]

Link to comment
Share on other sites

Im not familiar with it, but cant you write something unique to the register?

Greetings.

[list][font="Century Gothic"]If nothing is certain, everything is possible.[/font][/list][font="Century Gothic"]Experience is something you get, just after you need it.[/font]

Link to comment
Share on other sites

Im not familiar with it, but cant you write something unique to the register?

Greetings.

yes, but I believe he was looking for a means that was as difficult to work around as possible, which I would suggest the HDD serial, but even that, to the dedicated, has a work around.

You are best off taking a selection of several unique identifiers to make a key that would be too much trouble to change (ie, HDD serial + Windows Key + mac address + hwid).

[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

yes, but I believe he was looking for a means that was as difficult to work around as possible, which I would suggest the HDD serial, but even that, to the dedicated, has a work around.

You are best off taking a selection of several unique identifiers to make a key that would be too much trouble to change (ie, HDD serial + Windows Key + mac address + hwid).

Hey why don't u use the service tag of the m/c..

u can easily search it thru WMI

n its absolutely unique.

every m/c has it, n the manufacturers keep it unique

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
Link to comment
Share on other sites

trancexx

Hi! The above regular expression means, that we search for a set of any digit (0-9) and the "-" (dash) symbol. "+" means: Repeat the previous character, set or group 1 or more times. :lmao:

Actually, there were question inside my question. I thought you would get it.

My remark written in Autoit was this:

$RunPID = Run(@ComSpec & " /c wmic.exe csproduct get UUID", "", @SW_HIDE, 0x2)

Dim $sRead

While Not @error
    $sRead &= StdoutRead($RunPID)
WEnd

MsgBox(64, "Computer Universally Unique Identifer", $sRead)

So, your regexp is way off.

Further more, you are using wmic.exe for unknown reasons, to me anyway. That app is made for batch programming and similar stuff. AutoIt is above that by miles.

Your code should have been something like this:

MsgBox(64, "Computer Universally Unique Identifer", _GetUUID())

Func _GetUUID()

    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\localhost\root\cimv2")

    If Not IsObj($oWMIService) Then
        Return SetError(1, 0, -1)
    EndIf

    Local $oSysProd = $oWMIService.ExecQuery("Select * From Win32_ComputerSystemProduct")

    For $oSysProp In $oSysProd
        Return SetError(0, 0, $oSysProp.UUID)
    Next

    Return SetError(2, 0, -1)

EndFunc

Related link

They say it's easy to be general after the battle. I think I've just prove that :) (this is on me, but never mind)

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

  • Moderators

Unfortunately, this will fail on 50% of PC's (not everyone has WMI active).

I've often looked for a pure API method, from what I've read, you'd have to dig in the net bios and dig out the high and low time. I've never gotten it to work this way though.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Actually, there were question inside my question. I thought you would get it.

My remark written in Autoit was this:

$RunPID = Run(@ComSpec & " /c wmic.exe csproduct get UUID", "", @SW_HIDE, 0x2)

Dim $sRead

While Not @error
    $sRead &= StdoutRead($RunPID)
WEnd

MsgBox(64, "Computer Universally Unique Identifer", $sRead)

So, your regexp is way off.

Further more, you are using wmic.exe for unknown reasons, to me anyway. That app is made for batch programming and similar stuff. AutoIt is above that by miles.

Your code should have been something like this:

MsgBox(64, "Computer Universally Unique Identifer", _GetUUID())

Func _GetUUID()

    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\localhost\root\cimv2")

    If Not IsObj($oWMIService) Then
        Return SetError(1, 0, -1)
    EndIf

    Local $oSysProd = $oWMIService.ExecQuery("Select * From Win32_ComputerSystemProduct")

    For $oSysProp In $oSysProd
        Return SetError(0, 0, $oSysProp.UUID)
    Next

    Return SetError(2, 0, -1)

EndFunc

Related link

They say it's easy to be general after the battle. I think I've just prove that :) (this is on me, but never mind)

Without parsing using the StringRegExp I get this:

Posted Image

But I need to get only number, without unnecessary strings.

Link to comment
Share on other sites

  • Moderators

Without parsing using the StringRegExp I get this:

Posted Image

But I need to get only number, without unnecessary strings.

I think this was what you were looking to do:

Local $s_out = ""
Local $i_pid = Run(@ComSpec & " /c wmic csproduct get UUID", @SystemDir, @SW_HIDE, 6)
While 1
    $s_out &= StdoutRead($i_pid)
    If @error Then ExitLoop
WEnd
$s_out = StringRegExpReplace($s_out, "(?s)(.*?)(\w+-\w+-\w+-\w+-\w+)(.*?\z)", "$2")
ConsoleWrite($s_out & @CRLF)
One mistake was it's not just digits on the return.... Mine returns alpha numeric.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

$guid = StringReplace(StringTrimLeft(StringTrimRight(_CreateGuid(), 1), 1), '-', '')oÝ÷ Ù«­¢+ØÀÌØíÕ¥ôMÑÉ¥¹IÁ±¡MÑÉ¥¹IÁ±¡MÑÉ¥¹IÁ±¡}
ÉÑÕ¥ ¤°ÅÕ½ÐíìÅÕ½Ðì°ÌäìÌä줰ÅÕ½ÐíôÅÕ½Ðì°ÌäìÌä줰ÅÕ½Ðì´ÅÕ½Ðì°ÌäìÌäì¤

:)

Cheers, FireFox.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...