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

Re: vb script to join domain by Torgeir

Torgeir
Wed Sep 08 21:45:19 CDT 2004

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?selm=402AFB1E.B2D2F6F4%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/en-us/wmisdk/wmi/joindomainorworkgroup_method_in_class_win32_computersystem.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/community/scriptcenter/compmgmt/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/scriptcenter/default.mspx

Re: vb script to join domain by Jason

Jason
Thu Sep 09 11:14:53 CDT 2004

Thank you. I will work with the WMI method.

Jason

"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:e9WPrchlEHA.2020@TK2MSFTNGP09.phx.gbl...
> 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?selm=402AFB1E.B2D2F6F4%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/en-us/wmisdk/wmi/joindomainorworkgroup_method_in_class_win32_computersystem.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/community/scriptcenter/compmgmt/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/scriptcenter/default.mspx



Re: vb script to join domain by bob

bob
Mon Sep 27 22:26:21 CDT 2004

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...

Re: vb script to join domain by bob

bob
Mon Sep 27 22:32:53 CDT 2004

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...

Re: vb script to join domain by ()

()
Mon Sep 27 23:28:18 CDT 2004

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...