Home > Archive > VBScript > September 2004 > vb script to join domain
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
vb script to join domain
|
|
| Jason Dravet 2004-09-08, 8:55 pm |
| I am trying to write a script that will open the computer name changes
window in the system control panel. A friend gave the following:
Option Explicit
Dim oWS
Set oWS = WScript.CreateObject("WScript.Shell")
WScript.Sleep 5500
'Bring up the System Properties window
oWS.run "rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,1"
WScript.Sleep 1000
'Bring up the computer name changes window
oWS.SendKeys "%c"
WScript.Sleep 1000
oWS.SendKeys "%d"
WScript.Sleep 1000
oWS.SendKeys "{Tab}"
WScript.Sleep 500
oWS.SendKeys "test.local"
WScript.Sleep 500
oWS.SendKeys "{ENTER}"
Set oWS = nothing
The problem is the system properties window loses focus and the rest of the
commands don't register. Is there a way to directly bring up the computer
name changes window? Or is there a way to make the System Properties window
the focus?
Thanks,
Jason
| |
| Torgeir Bakken \(MVP\) 2004-09-09, 3:55 am |
| Jason Dravet wrote:
> I am trying to write a script that will open the computer name changes
> window in the system control panel. A friend gave the following:
>
> (snip SendKeys script)
>
> The problem is the system properties window loses focus and the rest of the
> commands don't register. Is there a way to directly bring up the computer
> name changes window? Or is there a way to make the System Properties window
> the focus?
Hi
SendKeys is unreliable as you have found out.
Using Netdom.exe is an alternative, more here:
http://groups.google.com/groups?sel...6F4%40hydro.com
To reboot the computer after the join, add /REBoot to
the command line of Netdom.exe.
If the computers are running Windows XP or newer, using
a WMI script is another option:
JoinDomainOrWorkgroup Method in Class Win32_ComputerSystem
http://msdn.microsoft.com/library/e...putersystem.asp
Here is a script from the technet Scripting Center that uses the
JoinDomainOrWorkgroup method:
Join Computer to a Domain
http://www.microsoft.com/technet/co...mt/scrcm31.mspx
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/sc...er/default.mspx
| |
|
|
| freakyjesus@hotmail.com 2004-09-28, 3:57 am |
| I was curious about the same thing myself, just tried this and it worked:
control.exe sysdm.cpl,,1.ComputerNameChanges
Hope it works in your script.
****************************************
******************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
| |
| freakyjesus@hotmail.com 2004-09-28, 3:57 am |
| Oops! Sorry, I already had that window open.
****************************************
******************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
| |
|
| Oops! Sorry, I already had that window open.
****************************************
******************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
|
|
|
|
|