Re: Router Configuration

From: Roland Hall (nobody_at_nowhere)
Date: 10/23/04


Date: Fri, 22 Oct 2004 21:31:08 -0500


"Brian Staff" <brianstaff@[NoSpam]compuserve.com> wrote in message
news:VA.0000029b.0e8b26c6@bstaffw2k.jda.corp.local...
:> netsh machine name=daugtersmachine offline
: >
: > this turns your dougters NIC off, and she won't be able to turn it on
from
: > windows.
:
: Thank-you so much...I think this will do exactly what I want. After
looking over the
: commands in MSDN, I have a question about your syntax: is "machine" the
actual word
: "machine" or is it the name of the router? I could not find the syntax you
suggested in the
: docs.
:
: Brian
:
: for those lurking, I found these:
:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netshell/netshell/netshell
: _root_context.asp

Actually that is incorrect for 2 reasons:
1. W2K and XP do not support diabling the NIC with netsh. You can however
change the address.
2. Depending on rights, she may or may not have access to set it back but
she would also need to know what to look for. Note: And if she doesn't have
rights to set it back, she cannot set it in the first place. Scripting
using impersonation might be an option here.

This will work on XP, I've tested it and it assumes you are currently using
DHCP to assign the correct network settings otherwise you will need to
change line 2 similar to line 1 with the correct settings.

To effectively disable her networking:
1. netsh interface ip set address="Interface Name" static 1.1.1.1 255.0.0.0
none

This sets:
IP Address: 1.1.1.1
Subnet Mask: 255.0.0.0
no gateway

To reenable it using DHCP
2. netsh interface ip set address="Interface Name" dhcp

If her network settings were static and not dynamic and assuming they were
192.168.0.2 255.255.255.0 DFG 192.168.0.1 change line 2 to:
netsh interface ip set address="Interface Name" static 192.168.0.2
255.255.255.0 192.168.0.1 1

"Interface Name" is double quotes around the name of the interface. By
default I think it is Local Area Connection but you can rename it. I named
mine LAN1. In my case "LAN1" would be used instead of "Interface Name".

So, what do you need to automate this and not have to worry about it?

I created 2 files: offline.cmd and online.cmd

-offline.cmd-
@echo off
netsh interface ip set address name="LAN1" static 1.1.1.1 255.0.0.0 none

-online.cmd-
@echo off
netsh interface ip set address name="LAN1" dhcp

I have mine in the root but I suggest you put yours somewhere else and don't
forget to either rename her interface or modify LAN1 to the interface name
she has.

I then entered these two commands in at the command prompt:

at 23:00 /every:M,T,W,Th,F,S,Su "c:\offline.cmd"
at 8:00 /every:M,T,W,Th,F,S,Su "c:\online.cmd"

Type: at by itself to see that they are scheduled.

To remove them one day, use: at /delete

The downside, if she finds it, she can change it, depending on rights. It's
something you have to look for and even though she may not know, she may
know someone who does. What I'm not sure of is if her computer is not on at
11pm, and she turns it on later, will it run the scheduled event. If not,
you'll have to work harder so that when the system is logged on it checks to
see if it is between 11pm and 8am and if so, run offline.cmd. This will
most likely require scripting.

If you need to script this, post back.
HTH...

-- 
Roland Hall
/* This information is distributed in the hope that it will be useful, but 
without any warranty; without even the implied warranty of merchantability 
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


Relevant Pages

  • Re: Unwanted Network config. changes after sysprep.
    ... but you might want to check out the Scripting ... And, standard, there is also the NetSH command line interface with such ... netsh interface ip set address ... Just to get an idea on how-to in a command prompt type: ...
    (microsoft.public.windowsxp.setup_deployment)
  • Re: 2nd user needs network but blocked from internet
    ... OK, I think I get how to use netsh and it should work, ... netsh interface ip set address "Local Area Connection" static 125.187.7.56 ... netsh interface ip set address "Local Area Connection" DHCP ...
    (microsoft.public.win2000.networking)
  • Re: explorer keeps crashing when network properties is entered
    ... You might try netsh from a command prompt; ... set primary dns server, 4 to set alt dns server, 5 to set ip address DHCP ... netsh interface ip set address name="Local Area Connection 2" ...
    (microsoft.public.win2000.general)
  • Re: Netsh
    ... "Derek" wrote: ... >I am new to scripting and I am trying to write a script using netsh that ... >present the end user with the option of choosing either static or dhcp as ...
    (microsoft.public.scripting.vbscript)
  • Re: Showing IP address
    ... Real command line junkies use netsh. ... netsh interface ip show address ... netsh wlan show all ...
    (alt.internet.wireless)

Quantcast