Windows Vista Forums

Startup-script to change hostname and IP if not OK
  1. #1


    IUnderstandSomething Guest

    Startup-script to change hostname and IP if not OK

    I have a classrom of computers where I use virtual machines with Linux
    as host and Win-XP as guests.

    After copying a VM they will all have the same hostname. I need a
    startup-script that will set the hostname and IP-adress from a premade
    INI-file I can store on the Linux-host.



    Anyone?

      My System SpecsSystem Spec

  2. #2


    Scott Guest

    Re: Startup-script to change hostname and IP if not OK

    "IUnderstandSomething" <hke1972@xxxxxx> schrieb im Newsbeitrag
    news:5d16f4f0-c690-42fd-b90c-39484f544157@xxxxxx

    >I have a classrom of computers where I use virtual machines with Linux
    > as host and Win-XP as guests.
    >
    > After copying a VM they will all have the same hostname. I need a
    > startup-script that will set the hostname and IP-adress from a premade
    > INI-file I can store on the Linux-host.
    >
    > Anyone?
    maybe this helps:
    http://stackoverflow.com/questions/5...m-command-line


    also netsh is good tool:
    http://www.petri.co.il/configure_tcp_ip_from_cmd.htm


    you may also try to use DHCP instead of static IP-Nr then no need to change
    IP settings

    bye



      My System SpecsSystem Spec

  3. #3


    Heinz Guest

    Re: Startup-script to change hostname and IP if not OK

    "IUnderstandSomething" <hke1972@xxxxxx> schrieb im Newsbeitrag
    news:64b97b9a-2a4c-4fee-9bcd-3e8beb86ff59@xxxxxx

    > Almost there
    >
    > I used what you said and read up on a lot of other stuff to and ended
    > up with this VBS-file:
    >
    > Const sName="Class2"
    > Dim objNet, objShell, strComputerName
    > Set objNet = CreateObject("WScript.NetWork")
    > strComputerName = objNet.ComputerName
    > if sName <> strComputerName then
    > set objShell = wscript.createObject("wscript.shell")
    > strTmp = "netsh interface ip set address name 'Local Area Connection'
    > static 192.168.10.22 255.255.255.0 192.168.10.1"
    > objshell.run strTmp,1,true
    > strTmp = "netsh int ip set dns 'Local Area Connection' dns 'Local
    > Area Connection' static 62.65.30.10"
    > objshell.run strTmp,1,true
    > strTmp = "B:\newSid.exe /a " & sName
    > objshell.run strTmp,1,true
    > Set objNet = Nothing
    > end if
    >
    > ??
    > I am, as you probably can see, trying to test if the computername is
    > as expected. If not to set IP etc. and DNS. Where I have been guessing
    > now is at the quates. Because netsh has Local Area Connection in " ,
    > but since I am running it with a shell I thought to change them with
    > ' , but it does not work.
    >
    > Ideas??
    >
    > Thank you!
    For the quote problem you can try this :

    strTmp = "netsh interface ip set address name " & chr(34) & "Local Area
    Connection" & chr(34)


    chr(34) stands for " - and I think if you build the string programtically
    it maybe works


    hth



      My System SpecsSystem Spec

  4. #4


    Darryl Guest

    Re: Startup-script to change hostname and IP if not OK

    On Jul 23, 7:36*pm, IUnderstandSomething <hke1...@xxxxxx> wrote:

    > I have a classrom of computers where I use virtual machines with Linux
    > as host and Win-XP as guests.
    >
    > After copying a VM they will all have the same hostname. I need a
    > startup-script that will set the hostname and IP-adress from a premade
    > INI-file I can store on the Linux-host.
    >
    > Anyone?
    I've been exploring this concept for my schools. How far have you
    got?

    darryl

      My System SpecsSystem Spec

Startup-script to change hostname and IP if not OK problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute powershell script at startup OlivierT PowerShell 2 09 Apr 2010
Hyper-V Startup Script Not Working Joe Virtual Server 0 27 Aug 2009
Startup Script Via GPO... Where Are Parameters Stored? trading_jacks VB Script 1 22 May 2009
Script works / but fails on startup newsgroups.jd VB Script 1 23 Feb 2009
Trivial startup script won't run in Vista Jeff Vandervoort Vista account administration 0 05 Aug 2007