Jump to content

script or multiple configurations to use different network settings


Recommended Posts

Posted

hi all,

 

i would appreciate your comments on the following,

 

- i have a pc, which i move to different subnets periodically, so each

time, i need to change:

.. pc name

.. ip addr

.. gateway

.. some enviroment variables

 

- would i do this automatically, that is, in example, with a script

written with programs and settings in command line mode (without

interacction with the user), and, if it is needed, rstart again?

 

- or any form of "multiple configuration", that i can choose in the

booting process???

 

tks in advance

  • Replies 4
  • Created
  • Last Reply
Guest Pegasus \(MVP\)
Posted

Re: script or multiple configurations to use different network settings

 

 

"rhXX" <rh00667@gmail.com> wrote in message

news:1189232107.034927.154230@y42g2000hsy.googlegroups.com...

> hi all,

>

> i would appreciate your comments on the following,

>

> - i have a pc, which i move to different subnets periodically, so each

> time, i need to change:

> . pc name

> . ip addr

> . gateway

> . some enviroment variables

>

> - would i do this automatically, that is, in example, with a script

> written with programs and settings in command line mode (without

> interacction with the user), and, if it is needed, rstart again?

>

> - or any form of "multiple configuration", that i can choose in the

> booting process???

>

> tks in advance

>

 

Changing the IP settings is easy, as is changing some

environmental variables (which ones?), but why would

you change the PC name? It requires a reboot each time!

Posted

Re: script or multiple configurations to use different network settings

 

On Sep 8, 10:28 am, "Pegasus \(MVP\)" <I....@fly.com> wrote:

> "rhXX" <rh00...@gmail.com> wrote in message

>

> news:1189232107.034927.154230@y42g2000hsy.googlegroups.com...

>

> Changing the IP settings is easy, as is changing some

> environmental variables (which ones?), but why would

> you change the PC name? It requires a reboot each time!

 

reset the pc is not a problem, because i must to turn off it, when i

move.

 

i am thinking in a group of script with the required data in each

case. so, before i turn off the pc, i run it ...

 

which commands must i use in the script?

 

tks in advance

Guest Pegasus \(MVP\)
Posted

Re: script or multiple configurations to use different network settings

 

 

"rhXX" <rh00667@gmail.com> wrote in message

news:1189258107.923747.8090@o80g2000hse.googlegroups.com...

> On Sep 8, 10:28 am, "Pegasus \(MVP\)" <I....@fly.com> wrote:

>> "rhXX" <rh00...@gmail.com> wrote in message

>>

>> news:1189232107.034927.154230@y42g2000hsy.googlegroups.com...

>

>>

>> Changing the IP settings is easy, as is changing some

>> environmental variables (which ones?), but why would

>> you change the PC name? It requires a reboot each time!

>

> reset the pc is not a problem, because i must to turn off it, when i

> move.

>

> i am thinking in a group of script with the required data in each

> case. so, before i turn off the pc, i run it ...

>

> which commands must i use in the script?

>

> tks in advance

>

 

Copy & paste the lines below into c:\Windows\Config1.vbs

(or into Config2.vbs).

 

Option Explicit

 

Const Adapter = "Local Area Connection"

Const Address = "192.168.44.45"

Const Gateway = "192.168.44.253"

Const ComputerName = "Computer2"

 

Dim ObjWShShell, ObjExec, ws

Set ws=CreateObject("WScript.Shell")

 

Set ObjExec = ws.Exec("netsh.exe interface IP Set address name=""" _

& Adapter & """ source=static addr=" & Address _

& " mask=255.255.255.0 gateway=" & Gateway & " gwmetric=1")

WScript.Echo("Waiting 30 seconds for the new addresses to be set")

WScript.Sleep(30000)

 

Set ObjExec = ws.Exec("cmd.exe /c sysdm.cpl")

WScript.Sleep(2000)

ws.SendKeys("{Right}%C")

WScript.Sleep(1000)

ws.SendKeys(ComputerName)

WScript.Sleep(1000)

ws.SendKeys("{Enter}")

WScript.Sleep(60000)

 

Invoke the script with this command:

cscript c:\windows\Config1.vbs

 

Note this: AFAIK, there is no inbuilt command to change

a computer's name. The above script does it with macros,

which is quite fragile because it depends on the expected

options being in the same place on your PC as on mine.

If you do not get the expected result, comment out the various

SendKey statements, starting from the bottom, by placing a

single quote (') in front of each line. Now check carefully

what each SendKey statement does and modify it to meet

the requirements on your machine.

 

I still do not think that it's a good idea to change your

computer's name.

Posted

Re: script or multiple configurations to use different network settings

 

On Sep 8, 9:05 pm, "Pegasus \(MVP\)" <I....@fly.com> wrote:

> "rhXX" <rh00...@gmail.com> wrote in message

>

> news:1189258107.923747.8090@o80g2000hse.googlegroups.com...

>

>

>

> > On Sep 8, 10:28 am, "Pegasus \(MVP\)" <I....@fly.com> wrote:

> >> "rhXX" <rh00...@gmail.com> wrote in message

>

> >>news:1189232107.034927.154230@y42g2000hsy.googlegroups.com...

>

> >> Changing the IP settings is easy, as is changing some

> >> environmental variables (which ones?), but why would

> >> you change the PC name? It requires a reboot each time!

>

> > reset the pc is not a problem, because i must to turn off it, when i

> > move.

>

> > i am thinking in a group of script with the required data in each

> > case. so, before i turn off the pc, i run it ...

>

> > which commands must i use in the script?

>

> > tks in advance

>

> Copy & paste the lines below into c:\Windows\Config1.vbs

> (or into Config2.vbs).

>

> Option Explicit

>

> Const Adapter = "Local Area Connection"

> Const Address = "192.168.44.45"

> Const Gateway = "192.168.44.253"

> Const ComputerName = "Computer2"

>

> Dim ObjWShShell, ObjExec, ws

> Set ws=CreateObject("WScript.Shell")

>

> Set ObjExec = ws.Exec("netsh.exe interface IP Set address name=""" _

> & Adapter & """ source=static addr=" & Address _

> & " mask=255.255.255.0 gateway=" & Gateway & " gwmetric=1")

> WScript.Echo("Waiting 30 seconds for the new addresses to be set")

> WScript.Sleep(30000)

>

> Set ObjExec = ws.Exec("cmd.exe /c sysdm.cpl")

> WScript.Sleep(2000)

> ws.SendKeys("{Right}%C")

> WScript.Sleep(1000)

> ws.SendKeys(ComputerName)

> WScript.Sleep(1000)

> ws.SendKeys("{Enter}")

> WScript.Sleep(60000)

>

> Invoke the script with this command:

> cscript c:\windows\Config1.vbs

>

> Note this: AFAIK, there is no inbuilt command to change

> a computer's name. The above script does it with macros,

> which is quite fragile because it depends on the expected

> options being in the same place on your PC as on mine.

> If you do not get the expected result, comment out the various

> SendKey statements, starting from the bottom, by placing a

> single quote (') in front of each line. Now check carefully

> what each SendKey statement does and modify it to meet

> the requirements on your machine.

>

> I still do not think that it's a good idea to change your

> computer's name.

 

ok, tks a lot! i will test, i will comment the results.

 

tks !!!!!!!!!


×
×
  • Create New...