NicePerson Posted March 26, 2011 Share Posted March 26, 2011 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.. Link to comment Share on other sites More sharing options...
AppTux Posted March 26, 2011 Share Posted March 26, 2011 (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 March 26, 2011 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26, 2011 Moderators Share Posted March 26, 2011 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
NicePerson Posted March 26, 2011 Author Share Posted March 26, 2011 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26, 2011 Moderators Share Posted March 26, 2011 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
UnknownWarrior Posted March 26, 2011 Share Posted March 26, 2011 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 englishUse 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 fileor2. (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 :/. Link to comment Share on other sites More sharing options...
NicePerson Posted March 26, 2011 Author Share Posted March 26, 2011 Melba, It should generate unique name every time on one computer.. Link to comment Share on other sites More sharing options...
AppTux Posted March 26, 2011 Share Posted March 26, 2011 (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 March 26, 2011 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26, 2011 Moderators Share Posted March 26, 2011 NicePerson, I am struggling to understand what it is you are trying to do here. It should generate unique name every time on one computerAre 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. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
NicePerson Posted March 26, 2011 Author Share Posted March 26, 2011 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.. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26, 2011 Moderators Share Posted March 26, 2011 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now