Sign in to follow this  
Followers 0
NicePerson

Generate a unique name

11 posts in this topic

Hi, some one knows how to generate a unique computer name?

Name should be very unique, i have to use this for identifying..

Sorry for my bad english..

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I would recommend a Random function with about 10 digits, that are about 10*10*10*10*10*10*10*10*10*10=10.000.000.000 = 10 billion possibilities, I don't think there would be double numbers, and if so, make another function that reads a file with all names, and if there is a double one created, just create another one and write it in the file. :)

Edited by AppTux

PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

NicePerson,

Something like this should do the trick: :)

$iLen = 7

$sName = ""

For $i = 1 To $iLen
    $sName &= Chr(Random(97, 122, 1))
Next

ConsoleWrite($sName & @CRLF)

Just increase the number of characters if you want even less chance of a repetition - although 7 already gives you 8,031,810,176 possible values. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I am trying to say that i have to generate a unique computer name which should be different on every computer..

Sorry for my bad english

Share this post


Link to post
Share on other sites

NicePerson,

I am trying to say that i have to generate a unique computer name which should be different on every computer..

What I have just posted will generate an (almost certainly) unique code each time it is run. What about that script does not do what you want? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I am trying to say that i have to generate a unique computer name which should be different on every computer..

Sorry for my bad english

Use any of the suggestions and above and what my suggestion would be is either:

1. Create a server where they TCPConnect to you and reads your server username file

or

2. (My favorite) - Create a MySql database and connect to that. Once they use the username, have their program write to the database on a separate value for that row something like 'checked'. So the next person who comes for a username will have the program search through the list until it finds an unchecked username and it'll use that. However, after you get a LOT of usernames, it may take some time to read that much data :/.

Share this post


Link to post
Share on other sites

Melba, It should generate unique name every time on one computer..

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Melba23's script does... You also can do it like this: (almost the same as Melba32's)

$Len = 10
$string = ""

For $i = 1 To $Len
  $Case = Random(0, 1, 1)
  If $Case = 0 Then;lower-case
    $string &= Chr(Random(97, 122, 1))
  ElseIf $Case = 1 Then;upper-case
    $string &= Chr(Random(65, 90, 1))
  EndIf
Next

ConsoleWrite($string & @CR)

Edit: whoa, didn't expected that much replies in a few moments :)

Edited by AppTux

PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

NicePerson,

I am struggling to understand what it is you are trying to do here. :)

It should generate unique name every time on one computer

Are you saying you want a machine to generate the same string unique to that machine each time the code is run on that machine?

If so then I would suggest looking at this thread. :)

If not then try to explain a little more clearly. :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

NicePerson,

Are you saying you want a machine to generate the same string unique to that machine each time the code is run on that machine?

If so then I would suggest looking at this thread. :)

M23

Yes, you understood..

Now help me doing this..

Share this post


Link to post
Share on other sites

NicePerson,

Have you read the thread I linked to? There are a couple of code snippets posted there which should do what you want. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0