script or multiple configurations to use different network settings

  • Thread starter Thread starter rhXX
  • Start date Start date
R

rhXX

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
 
rhXX said:
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!
 
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
 
rhXX said:
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.
 
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 !!!!!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top