Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Update the logged in users name as the description of the computer.

Hi,

I want a script to update the logged in users name as the Description of the computer Object.Is there a way to do this.And i want to do this only for a particlar OU.

Regards
Sharath
Avatar of roamingllama
roamingllama

Sure is.  Use the script below:

Const MY_COMPUTER = &H11&
Set objNetwork = CreateObject("Wscript.Network")
strUsername = objNetwork.UserName
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
objFolderItem.Name = strUsername

Save that into a vbs file (i.e. "ChangeIconName.vbs").  If you want to add it to a batch file login script simply use this command:
wscript.exe "ChangeIconName.vbs"

Just realized I didnt answer the 2nd part of your question.  You can have this done for a certain OU by simply adding the script as a login script to the OU's GPO.  If it does not have a GPO assigned you can create a new one.

Be careful though if the GPO is assigned to multiple OU's the script will run for all that it is assigned too.

Thanks,
Dan
Avatar of bsharath

ASKER

roamingllama

This is changing the Mycomputer to the logged in name.

Start > you have My Computer its changing that to the logged in user name
ASKER CERTIFIED SOLUTION
Avatar of roamingllama
roamingllama

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
roamingllama

How do i automate this .

I just want to run this on a computers which will update the logged in users name...
Just copy the code into a vbs file (i.e. desc_change.vbs).  Then you can do it 1 of 2 ways. (1) If you already have login scripts for the users you cn simply add this to that login script (if it is a bat file or cmd file just use "wscript.exe desc_change.vbs").  Also make sure that the file is saved in the netlogon folder. (2) If you dont currently have login scripts you can add on to the GPO that is assigned to the users you want to apply it to and add it as a login script in there.
Any way to take the machine names from the file in which i have there names...

Not sure I follow you.  This script will automatically change the Computers Description to the username that is logged in.  So let's say your username is "bsharath" and you login to machine pc01.  pc01's description would then become "bsharath" automatically.