![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Any Help - Scripting Newbie Hi All, I have a job to do over in Rominia with work and was hoping someone could make my life a little easier? Im after a VB script we could run on the machine which will prompt us for a IP Address, Subnet Mask, Gateway Address, DNS 1, DNS 2, Computer Name, Computer Description, and, What Domain to add the machine to, and then go and set it from the input given? Anybody got any ideas? or a script that could do the above? I`ve googled but am getting a little lost and to be honet running out of time a little ![]() Any help would be greatly appriciated. Many Thanks Best Regards Si |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Any Help - Scripting Newbie I am not aware of a VB Script method to set the various IP parameters. However, netsh.exe will do it, after a little practice on your part. While you could use a series of VB Script "InputBox" statements to acquire the various parameters, it might be more consistent to use a batch file of the following form: @echo off set /p IP=Please enter the IP address: if "%IP%"=="" goto :eof set /p Subnet=Please enter the Subnet Mask: if "%Subnet%"=="" goto :eof etc. netsh.exe .. .. .. As far as joining a domain: Below is a script that's supposed to do it. I picked it up from a newsgroup some time ago but have never tested it myself. Const JOIN_DOMAIN = 1 Const ACCT_CREATE = 2 Const ACCT_DELETE = 4 Const WIN9X_UPGRADE = 16 Const DOMAIN_JOIN_IF_JOINED = 32 Const JOIN_UNSECURE = 64 Const MACHINE_PASSWORD_PASSED = 128 Const DEFERRED_SPN_SET = 256 Const INSTALL_INVOCATION = 262144 strDomain = InputBox("Enter Domain name to Join") strUser = InputBox("Enter Domain User to join domain") strPassword = Inputbox("Enter password") Set objNetwork = CreateObject("WScript.Network") strComputer = objNetwork.ComputerName Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" _ & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" _ & strComputer & "'") ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _ strPassword, _ strDomain & "\" & strUser, _ "cn=Computers,DC=mydomain,dc=com", JOIN_DOMAIN + ACCT_CREATE) If ReturnValue = 0 Then MsgBox "Computer added to domain. " Else MsgBox "Computer not added to domain successfully. Return value: " & ReturnValue End If "Im Going Mad" <imgoingmad@xxxxxx> wrote in message news:uEKlvaEDJHA.5196@xxxxxx Quote: > Hi All, > > I have a job to do over in Rominia with work and was hoping someone could > make my life a little easier? > > Im after a VB script we could run on the machine which will prompt us for > a IP Address, Subnet Mask, Gateway Address, DNS 1, DNS 2, Computer Name, > Computer Description, and, What Domain to add the machine to, and then go > and set it from the input given? > > Anybody got any ideas? or a script that could do the above? I`ve googled > but am getting a little lost and to be honet running out of time a > little ![]() > > Any help would be greatly appriciated. > > Many Thanks > Best Regards > Si |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Any Help - Scripting Newbie I've used almost the exact same script to join computers to a domain with success. To use VBScript to configure network settings these examples in the Script Center may help: http://www.microsoft.com/technet/scr...y/default.mspx -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- "Pegasus (MVP)" <I.can@xxxxxx> wrote in message news:eHhL8KFDJHA.2060@xxxxxx Quote: >I am not aware of a VB Script method to set the various IP parameters. >However, netsh.exe will do it, after a little practice on your part. While >you could use a series of VB Script "InputBox" statements to acquire the >various parameters, it might be more consistent to use a batch file of the >following form: > > @echo off > set /p IP=Please enter the IP address: > if "%IP%"=="" goto :eof > set /p Subnet=Please enter the Subnet Mask: > if "%Subnet%"=="" goto :eof > etc. > netsh.exe .. .. .. > > As far as joining a domain: Below is a script that's supposed to do it. I > picked it up from a newsgroup some time ago but have never tested it > myself. > > Const JOIN_DOMAIN = 1 > Const ACCT_CREATE = 2 > Const ACCT_DELETE = 4 > Const WIN9X_UPGRADE = 16 > Const DOMAIN_JOIN_IF_JOINED = 32 > Const JOIN_UNSECURE = 64 > Const MACHINE_PASSWORD_PASSED = 128 > Const DEFERRED_SPN_SET = 256 > Const INSTALL_INVOCATION = 262144 > strDomain = InputBox("Enter Domain name to Join") > strUser = InputBox("Enter Domain User to join domain") > strPassword = Inputbox("Enter password") > Set objNetwork = CreateObject("WScript.Network") > strComputer = objNetwork.ComputerName > Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" > _ > & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" _ > & strComputer & "'") > ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _ > strPassword, _ > strDomain & "\" & strUser, _ > "cn=Computers,DC=mydomain,dc=com", JOIN_DOMAIN + ACCT_CREATE) > If ReturnValue = 0 Then > MsgBox "Computer added to domain. " > Else > MsgBox "Computer not added to domain successfully. Return value: " & > ReturnValue > End If > > > > "Im Going Mad" <imgoingmad@xxxxxx> wrote in message > news:uEKlvaEDJHA.5196@xxxxxx Quote: >> Hi All, >> >> I have a job to do over in Rominia with work and was hoping someone could >> make my life a little easier? >> >> Im after a VB script we could run on the machine which will prompt us for >> a IP Address, Subnet Mask, Gateway Address, DNS 1, DNS 2, Computer Name, >> Computer Description, and, What Domain to add the machine to, and then go >> and set it from the input given? >> >> Anybody got any ideas? or a script that could do the above? I`ve googled >> but am getting a little lost and to be honet running out of time a >> little ![]() >> >> Any help would be greatly appriciated. >> >> Many Thanks >> Best Regards >> Si > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Any Help - Scripting Newbie "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in message news:uDfVSVFDJHA.2480@xxxxxx Quote: > I've used almost the exact same script to join computers to a domain with > success. > > To use VBScript to configure network settings these examples in the Script > Center may help: > > http://www.microsoft.com/technet/scr...y/default.mspx > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| UAC and scripting | Vista General | |||
| NewBie to Scripting | PowerShell | |||
| ps scripting newbie - how to make functions/scripts available in the shell? | PowerShell | |||
| scripting newbie | PowerShell | |||
| Scripting bug? | PowerShell | |||