Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 complete noob with vbs...

Author  Topic 

jhermiz

3564 Posts

Posted - 2006-03-17 : 10:33:33
We are switching some domain users and need to add users to a group.
I found this article :

http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct04/hey1008.mspx?pf=true

The last gray area section with this code is what I want to do:

strComputer = "atl-ws-01"
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
Set objUser = GetObject("WinNT://fabrikam/kenmyer")
objGroup.Add(objUser.ADsPath)


Question is, in vbs is it possible to get the computer name? For instance, if I open a dos prompt and type set computername it displays the computer name. Is there any way to retreive that?

Also is it possible to grab the user name (in the above example the user is kenmyer). So the currently logged in NT user.

My last question is do I just copy this code into notepad and save as .vbs ?

Thanks so much!

Jon



Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]

RS Blog -- [url]http://weblogs.sqlteam.com/jhermiz[/url]

jhermiz

3564 Posts

Posted - 2006-03-17 : 10:54:29
Ok I actually got most of that :

Set wshNetwork = WScript.CreateObject("Wscript.Network")


strUserName = wshNetwork.UserName ' Get user name
strComputerName = wshNetwork.computername ' Get machine name
strUserDomain = wshNetwork.UserDomain ' Get user domain

Set objGroup = GetObject("WinNT://" & strComputerName & "/Administrators")

Set objUser = GetObject("WinNT://JAKAH/Domain Users")
Set objUser2 = GetObject("WinNT://JAKAH/Domain Admins")

objGroup.Add(objUser.ADsPath)
objGroup.Add(objUser2.ADsPath)


But my next question is, is it possible to change the domain group of a pc using vbs?
If I right click my computer and go to properties and I click on the "Computer Name" tab there is a button: "Change"
In there it says Member of: Domain: and the domain name. Is it possible to change that domain name in vbs ?

Thanks,

Jon



Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]

RS Blog -- [url]http://weblogs.sqlteam.com/jhermiz[/url]
Go to Top of Page

jhermiz

3564 Posts

Posted - 2006-03-17 : 13:13:25
Well we found a script for the second request so I guess I can mark this one resolved :).



Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]

RS Blog -- [url]http://weblogs.sqlteam.com/jhermiz[/url]
Go to Top of Page
   

- Advertisement -