Does anyone have a script that would popup a box pre-install to "Assign" the computer to a individual. For example, on a massive deployment you might have a list of computers you need to create with computer names :

Computer Name User Serial Number
VTPHILK Joe Smo XX22XX22

So I would like a pre-install script that would pop a HTA or box and ask what this computers name and user should be. I would input "Joe Smo" and "VTPHILK" and it would image the PC and insert the "Joe Smo" in the USER field of the computer, and auto name it "VTPHILK" and join to the domain? Then grab the serial number and push to the hardware inventory.

Is this something that exists already?

I'm using KImages and K2200 v3.3

Thanks!
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
What I do is let the system join my domain with a randomly generated name. Then, I run a post-install script to rename it automatically using the logged in user - we name our machines based on username. You can probably find a script to do it by prompting the user (or you could modify the VBS for the built-in post-install task that does this in the K2000). Or, you could automatically rename the system based on the serial number - if that is your goal.
Answered 02/28/2011 by: airwolf
Tenth Degree Black Belt

Please log in to comment
0
Although this won't do everything you need it can certainly provide part of a solution for you. Please go through the README included in the .zip for how it works. There are 2 .exes, the one called Getcomputername.exe is a preinstall task. Instead of running it as just getcomputername.exe, run it as getcomputername.exe /dialog
This will popup the dialog you requested during the preinstallation process.
The setcomputername is mid-level task that will apply the computername to a an xp/vista/win7 deployment whether it is a scripted install or an image.


All our scripts are posted here for now: http://www.kace.com/support/kb/index.php?action=artikel&cat=5&id=1125&artlang=en
Answered 02/28/2011 by: cserrins
Red Belt

Please log in to comment
0
I have done it like this:

Pre installation task: Vbs script that create a popup asking for PC name, it then copies another script I've created to the T drive (petemp folder) and edit a replacement value for later use. the file is called the MAC address.
Post install task: run "T:\%MAC_address.vbs" this replaces various values like PC name, language etc in the "C:\$WIN_NT$.~BT\winnt.sif" file
Post install task, after WinPE: Last installation task I've created copies a script that is running in "RunOnce" at next boot that ask who the user should be of the PC, this way it is also more flexible, if a user changes or I can have PC's in storage that is installed, but haven't been assigned users :)

I hope this helps =)

I don't mind posting some scripts, but they are acually alot more complext than just that, but if you like I can edit them a bit so they just do that =)
Answered 03/01/2011 by: rmeyer
Second Degree Blue Belt

Please log in to comment
0
Please post away..or PM. I would love to see some examples if you don't mind!

Thanks
Answered 03/01/2011 by: vtphilk
Orange Senior Belt

Please log in to comment
0
I have removed some of the parts you don't need like setting language settings and other stuff, this only set the PC name and generate a random local admin password (I store that in a sql db, but have taken that part out)

I hope you can use this :)

Pre install script, notis the "Y:\preinstall\15\settings.vbs" part, that need to be changed in order to be the correct script it downloads :)

On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set diskDrives = fso.Drives
Set wshShell = CreateObject("WScript.Shell")
compName="Tralalala"

'Dump the computer name into a file named as the mac address inside T:
If fso.DriveExists("T:") then
'Get mac adress
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
Wscript.Echo "MAC: " & objItem.MACAddress
macAddress=objItem.MACAddress
Next
macAddress=Replace(macAddress,":","")
Wscript.Echo "MAC: " & macAddress
' Set compNameFile = fso.CreateTextFile("T:\" & macAddress & ".txt", True)
Else
usbDrive = fso.GetDriveName(wscript.ScriptFullName)
Set compNameFile = fso.CreateTextFile(usbDrive & "\KACE\ComputerName", True)
End If
compNameFile.WriteLine(compName)
compNameFile.Close

' delete
'Set fso = CreateObject("Scripting.FileSystemObject")
'Set aFile = fso.GetFile("T:\" & macAddress)
'aFile.Delete

'wscript.echo "delete done"
' copy
Set fso = CreateObject("Scripting.FileSystemObject")
'Set aFile = fso.CreateTextFile(".\output.dat", True)
'aFile.WriteLine("1234")
'Set aFile = fso.GetFile(".\output.dat")
'aFile.Copy("./output.bak")

' alternate
fso.CopyFile "Y:\preinstall\15\settings.vbs", "T:\" & macAddress & ".vbs",TRUE

PCNAME_id=PromptUser("Please type in Computername", "Please Type in Computername", "")

OK=ReplaceValue("T:\" & macAddress & ".vbs","-PCNAME_id-",PCNAME_id)


Function PromptUser(Title, Message, textfield)

' Define dialog box variables.
'Message = "Please enter language, ie: DK"
'Title = "Please enter the language for your PC"
Text1 = "User input canceled"
Text2 = "You entered:" & vbCrLf
PromptUser = InputBox(Message, Title, textfield)

' Evaluate the user input.
If PromptUser = "" Then ' Canceled by the user
WScript.Echo Text1
PromptUser=error
Else
WScript.Echo Text2 & PromptUser
End If

End Function



Function ReplaceValue(FileName, OldTxt, NewTxt)
Const ForReading = 1
Const ForWriting = 2

strFileName = FileName
strOldText = OldTxt
strNewText = NewTxt

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileName, ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, strOldText, strNewText)

Set objFile = objFSO.OpenTextFile(strFileName, ForWriting)
objFile.WriteLine strNewText
objFile.Close
End Function


Post Installation script: ( that is this: "Y:\preinstall\15\settings.vbs" )

'Option Explicit
'On Error Resume Next
Dim Title, NumChar, Count, strRdm, intRdm

CompName="-PCNAME_id-"
Set fso = CreateObject("Scripting.FileSystemObject")
Set diskDrives = fso.Drives
Set wshShell = CreateObject("WScript.Shell")

'Dump the computer name into a file named as the mac address inside T:
If fso.DriveExists("T:") then
'Get mac adress
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
Wscript.Echo "MAC: " & objItem.MACAddress
macAddress=objItem.MACAddress
Next
macAddress=Replace(macAddress,":","")
Wscript.Echo "MAC: " & macAddress
Set compNameFile = fso.CreateTextFile("T:\" & macAddress & ".txt", True)
Else
usbDrive = fso.GetDriveName(wscript.ScriptFullName)
Set compNameFile = fso.CreateTextFile(usbDrive & "\KACE\ComputerName", True)
End If
compNameFile.WriteLine(compName)
compNameFile.Close

NumChar = 12
Randomize Timer
Do Until Count = NumChar
Count = Count + 1
GetRdm
strRdm = strRdm & Chr(intRdm)
Loop
' Wscript.Echo "SET ADMINPASS=" & strRdm
Sub GetRdm
intRdm = Int((122 - 49) * Rnd + 48)
If intRdm > 57 And intRdm < 65 Or intRdm > 90 And intRdm < 97 Then GetRdm
End Sub
LocalPassword=strRdm
wscript.echo "Password: " & LocalPassword
dim OK
'Replace variabler
OK=ReplaceValue("C:\$WIN_NT$.~BT\winnt.sif","_WKSPASS_",strRdm)
OK=ReplaceValue("C:\$WIN_NT$.~BT\winnt.sif","_PCID_","-PCNAME_id-")


Function ReplaceValue(FileName, OldTxt, NewTxt)
Const ForReading = 1
Const ForWriting = 2

strFileName = FileName
strOldText = OldTxt
strNewText = NewTxt

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileName, ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, strOldText, strNewText)

Set objFile = objFSO.OpenTextFile(strFileName, ForWriting)
objFile.WriteLine strNewText
objFile.Close
End Function



And last installation step:
I have a group called "Sharedlaptop" that all domain users are in, so all users have admin access to PC's untill it is removed that gives them access to run this script
strComputer = "."
dim adminuser, answer
'adminuser = InputBox("Please type the initials of the owner of the PC:" & Chr(10) & "Type SharedLaptop to leave it as a shared laptop", "Who should the PC be assigned to.")

answer = "Result of script:" & Chr(10)


Set oNetwork = CreateObject("WScript.Network")
sDomain = oNetwork.UserDomain
sADSPath= sDomain & "/" & adminuser

Set objAdmins = GetObject("WinNT://" & strComputer & "/Administrators")


Dim oShell, platform
Set oShell = WScript.CreateObject ("WScript.Shell")
platform=oShell.ExpandEnvironmentStrings("%Platform%")

if ucase(platform) = "DESKTOP" Then
Set objGroup = GetObject("WinNT://YourDomain/SharedDesktop")
End if

If ucase(platform) = "LAPTOP" Then
Set objGroup = GetObject("WinNT://YourDomain/SharedLaptop")
End if

If ucase(platform) = "VMWARE" Then
Set objGroup = GetObject("WinNT://YourDomain/SharedDesktop")
end if

'On Error Resume Next


if objAdmins.ismember(objGroup.adspath) then

answer = answer & adminuser & " was already member of to local administrator group" & Chr(10)
end if
if not objAdmins.ismember(objGroup.adspath) then
answer = answer & "SharedLaptop was added to local administrator group" & Chr(10)
if ucase(adminuser) <> ucase("SharedLaptop") then
answer = answer & "Sharedlaptop was removed from local administrator group" & Chr(10)
End if

objAdmins.add objGroup.adspath
end if


'wscript.echo answer


Answered 03/01/2011 by: rmeyer
Second Degree Blue Belt

Please log in to comment
0
oh, and in the installation "Setup configuration" you should change to the following:


[UserData]
ComputerName = "_PCID_"

[GuiUnattended]
AdminPassword = "_WKSPASS_"

:)

edit:

the enviroment %Platform% is one I set during installation to make it easiere for my self incase you wonder why you don't have it =)
Answered 03/01/2011 by: rmeyer
Second Degree Blue Belt

Please log in to comment
0
Very nice. Thanks for sharing that. I don't need it with the way we're doing things now, but that could come in handy down the road.


ORIGINAL: rmeyer

oh, and in the installation "Setup configuration" you should change to the following:


[UserData]
ComputerName = "_PCID_"

[GuiUnattended]
AdminPassword = "_WKSPASS_"

:)

edit:

the enviroment %Platform% is one I set during installation to make it easiere for my self incase you wonder why you don't have it =)
Answered 03/01/2011 by: dyehardfan
Second Degree Blue Belt

Please log in to comment
0
Awesome..Thanks! What you mean by updated the "Setup Configuration"

[UserData]
ComputerName = "_PCID_"

[GuiUnattended]
AdminPassword = "_WKSPASS_"

Are you talking about the XML file? Should I put that at the bottom or update the field within? Or you talking about the UserData part of the XML?

<UserData>
<AcceptEula>true</AcceptEula>
<Organization>MYCOMPANY</Organization>
<ProductKey>
<Key>33PXH-7Y6KF-2VJC9-XBBR8-HVTHH</Key>
<WillShowUI>OnError</WillShowUI>
</ProductKey>
</UserData>
Answered 03/01/2011 by: vtphilk
Orange Senior Belt

Please log in to comment
0
Ah for Win7 you need to set the "<computername>" component to something like this:

<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<ComputerName>*</ComputerName>
</component>


Change this:
OK=ReplaceValue("C:\$WIN_NT$.~BT\winnt.sif","_PCID_","-PCNAME_id-")
To this:
OK=ReplaceValue("C:\Windows\Panther\unattend.xml","<ComputerName>*</ComputerName>","<ComputerName>-PCNAME_id-</ComputerName>")

since it's another file and some other values :)
Answered 03/01/2011 by: rmeyer
Second Degree Blue Belt

Please log in to comment
0
I'm having trouble understanding where you are copying from "Y:\preinstall\15\settings.vbs". Is that something on the network or does the boot image auto create that or something?
Answered 03/02/2011 by: vtphilk
Orange Senior Belt

Please log in to comment
0
Ok..i figured it out..I see the PE mounts "net use Y:\\<IP OF RSA>\peinst" and "net use T:\\<IP OF RSA>\petemp". Then your script is using the petemp to store the script info. I was wondering why it was important to use the MAC but now I know :). I'm testing a install now.
Answered 03/02/2011 by: vtphilk
Orange Senior Belt

Please log in to comment
0
ok great =)
Answered 03/03/2011 by: rmeyer
Second Degree Blue Belt

Please log in to comment
0
I'm still having problems with it having the PC end up with a name of _PCID_ or whatever.. It seems to be writting the file to PETEMP but not renaming..
Answered 03/03/2011 by: vtphilk
Orange Senior Belt

Please log in to comment
0
PS..this is a windows 7 x64 install..just wondering if that could be the problem..
Answered 03/03/2011 by: vtphilk
Orange Senior Belt

Please log in to comment
0
I don't know why but I am really having trouble with this. The basic goal I am looking for is as follows:

Prompt for a computer name during pre-install, then run a scripted install. This computer name will typically be the same as the username of the user using it.

Next, postinstall winpe script will fire off use that computer name to replace the unattend.xml computer name with the one from pre-install.

Finally, the postinstall windows script runs which adds the user to the domain local admins user group.


I thought this would not be to hard with the K2200 but it is proving otherwise. The scripted install I have about 4 applications in (Antivirus, Office, 2 VPN clients and firefox) and it is running almost 45 minutes to install. I was hoping to get the speed a little faster since we have over 500 machines to image.

I will post the code for what I am using now as I had to heavily modify the above code for W7 and I think rmeyer removed alot of pieces
Answered 03/03/2011 by: vtphilk
Orange Senior Belt

Please log in to comment
0
hehe sorry :)
in the setup file in KACE, what did you write ?
This: <ComputerName>*</ComputerName>
or this: <ComputerName>_PCID_</ComputerName>


it have to be the same as this line or it won't change it :)

OK=ReplaceValue("C:\Windows\Panther\unattend.xml","<ComputerName>*</ComputerName>","<ComputerName>-PCNAME_id-</ComputerName>")
Answered 03/03/2011 by: rmeyer
Second Degree Blue Belt

Please log in to comment
0
Yes..I left it default, with *. I will doublecheck again..
Answered 03/04/2011 by: vtphilk
Orange Senior Belt

Please log in to comment
0
Maybe I'm overlooking something- but why not let the computers get delivered to the end user with a randomized name, then have a K1000 script run a rename script against the machine using wsname?
An online script could be configured to run as the logged on user, then the verify stage could look for a key the says if it's already ran, the remediation phase could run a step to run the wsname, then set the key that's detected in the verify step.
The wsname command might look like this:
wsname.exe /n:$USERID-$SERIALNUM /rcid /user:mydomain\admin /passm:adminpassword

Just a thought from a different angle- Wsname has some other options for injecting names into sysprep so you could potentially run it as a mid-level postinstall task and have an answer file that contains all your serial numbers or mac addresses and desired new host names. Enable sysprep integration checkbox on your image. I haven't personally tried this, but I'd think it might work rather well.

More documentation on WSNAME: http://mystuff.clarke.co.nz/MyStuff/wsname.asp
Answered 03/04/2011 by: cblake
Red Belt

Please log in to comment
0
So that is a thought as well.. However, I have not idea what you are talking about when you say remediation phase etc.. :)

We do also have the K1000. So what you are saying is let each computer have a randomized name during imaging. Then also join them to the domain with that random name during K2000 imaging? Then, have the user login to the PC and at that point the K1000 runs some sort of script to rename the computer on the domain?

Am I following you right?

I'm thinking that this might be a better route. Just do a vanilla image of every machine. Get the computers to the desktops of the user and then have some first time login script which fires off and renames them to the proper name of the computer (We just want to name the computer the persons userid) then joins that username to the admin rights on that PC then reboots.

Any thoughts (or scripts) on that? :)
Answered 03/05/2011 by: vtphilk
Orange Senior Belt

Please log in to comment
0
FYI...KACE support has provided me with what appears to be a AUTOIT script which is working great! So the rename is working :)
Answered 03/08/2011 by: vtphilk
Orange Senior Belt

Please log in to comment
0
Yes, this is an autoit script created by myself and Kent Feid. This will get the computer name from the machine and store it on petemp as a mac address file. It can also be used with a /dialog command to pop-up a dialog in case the machine is new. Also can be deployed with /name:computername for one-offs. The setcomputername task works with images AND scripted installs, which is one of the biggest differences between our script and the default script. You can pm me anytime if you would like these scripts. Maybe we can convince higher-ups to give us a space to upload pre/post tasks to share.

3/10/11 - If I sent you the link previously, I updated the script on 3/9/11, so you may want the latest copy at the same link. Hold on to that link and I'll update this page when I update the script. Read the README for details, including a new /timeout:seconds switch if you want.

We are open to ideas, please feel free to comment and suggest.

Corey
Answered 03/09/2011 by: cserrins
Red Belt

Please log in to comment
0
All,

i have a question which is close to this one.

I would like to get a popup box asking for the computername or something like it, @cserrins you mention a zip file, do you mind sharing it?

what i've tried is the get computername.vbs and things like it, worked with wsname and t:\names.db , but none of them do the trick..

can anyone please assist me on this matter?

thx!!
Answered 04/18/2011 by: syseng99
Yellow Belt

Please log in to comment
0
Not sure if this can help you but maybe it will be useful to someone else?

This will prompt for computer-name, username, and password. The user is a user who has rights to change domain PC name.

Dependencies I've only tested on Windows 7 x64:
In same the folder as this script you must have.

netdom.exe
renameComputer.vbs (This script)
In subfolder named EN-US you must have netdom.exe.mui

I zipped these all up and uploaded to kbox.

This is run as a post-install task, assuming PC is joined to domain already via untended file:


'Rename Computer prompt
'

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

strNewComputer = InputBox("Rename Computer","Enter the New Computer Name")
strUserName = InputBox("UserName","Enter Username")
strPassword = InputBox("Password", "Enter Password")

strRunThisNow = "netdom.exe" & " renamecomputer " & strComputer & " /NewName:" & strNewComputer & " /UserD:" & strUserName & " /PasswordD:" & strPassword



Select Case strNewComputer


Case ""

Case Else
wscript.echo strRunThisNow

Dim objSh

Set objSh = createObject("wscript.shell")

objSh.run "cmd.exe /K " & strRunThisNow
Set objsh = nothing





End Select
Answered 04/23/2011 by: luiznbecky
Yellow Belt

Please log in to comment
3
The Get/Set Computer Name script has been updated to version 1.1.1.2.
Both the get and set scripts limit the name to 15 characters, regardless of what user enters, or what the script gathers from previous name, the computername will never be more than 15 characters.

You can download this and other Scripting Ninja scripts from : http://www.kace.com/support/kb/index.php?action=artikel&cat=5&id=1125&artlang=en
Answered 03/06/2012 by: cserrins
Red Belt

Please log in to comment
0
ORIGINAL: luiznbecky

Not sure if this can help you but maybe it will be useful to someone else?

This will prompt for computer-name, username, and password. The user is a user who has rights to change domain PC name.

Dependencies I've only tested on Windows 7 x64:
In same the folder as this script you must have.

netdom.exe
renameComputer.vbs (This script)
In subfolder named EN-US you must have netdom.exe.mui

I zipped these all up and uploaded to kbox.

This is run as a post-install task, assuming PC is joined to domain already via untended file:


'Rename Computer prompt
'

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

strNewComputer = InputBox("Rename Computer","Enter the New Computer Name")
strUserName = InputBox("UserName","Enter Username")
strPassword = InputBox("Password", "Enter Password")

strRunThisNow = "netdom.exe" & " renamecomputer " & strComputer & " /NewName:" & strNewComputer & " /UserD:" & strUserName & " /PasswordD:" & strPassword



Select Case strNewComputer


Case ""

Case Else
wscript.echo strRunThisNow

Dim objSh

Set objSh = createObject("wscript.shell")

objSh.run "cmd.exe /K " & strRunThisNow
Set objsh = nothing





End Select




Amazing stuff,Thanks so much for this!This is very useful post for me. This will absolutely going to help me in my projects .


-----------------------------------------------------------------------------
[url=http://www.dressale.com/wedding-dresses-mermaidtrumpet-wedding-dresses-c-2_3_25.html]Trumpet Wedding Dresses[/url]|[url=http://www.dressale.com/wedding-dresses-new-style-wedding-dresses-c-2_3_18.html]New Style Wedding Dresses[/url]|[url=http://www.dressale.com/wedding-dresses-sheathcolumn-wedding-dresses-c-2_3_23.html]Column Wedding Dresses[/url]
Answered 03/07/2012 by: zhuo1005
Yellow Belt

Please log in to comment

Please log in to comment
Answer this question or Comment on this question for clarity

Share