calin radoni's humble web presence

homedocstoolboxabout

Command Line Usefull Tools

Table of Contents

Reason

Not quite often, I have only command prompt access to Windows hosts. It is time consumming to search again and again after command line tools and their usage, so this document may fill some gaps.

IP configuration

Here are some the ipconfig's paramaters:

Change the static IPv4 address from command line

The netsh tools is very powerfull in Windows world. Changing a static IPv4 address is trivial.

netsh local static <the-new-IPv4-address> <the-new-mask> <the-new-gateway> <the-metric>
        
Example:
netsh local static 192.168.1.2 255.255.255.0 192.168.1.1 0
        

Local users

Show local users

By issuing the command net user you will get the list of local users

Adding a local user

To add the "johndoe" user with the password "DoeJohn" and the full name "John Doe":

net user johndoe DoeJohn /add /passwordreq:yes /fullname:"John Doe"
          
and making it a member of the "SomeUsers" group:
net localgroup SomeUsers johndoe /add
          

The net user and net localgroup have many other options.
For domain based groups there is the net group command.

Network shares

To map the "Public" share from the "192.168.1.1" server as the local disk "N":

net use N: \\192.168.1.1\Public
        
If you want to use a different user, let's say "johndoe":
net use N: \\192.168.1.1\Public /user:johndoe
        

Shutdown or Restart from command line

The C:\Windows\System32\tsshutdn.exe utility can be used to shutdown or restart a Windows (2000, XP, 2003) computer from command line.
According to Microsoft's KB320188, the usage is:

tsshutdn wait_time [/server:server_name] /reboot /powerdown /delay:log_off_delay /v
        
where:

Windows firewall

Operational mode
To see the firewall's state, configuration and working mode issue the following commands:

Allowing a port
To allow a port through firewall execute:
netsh firewall add portopening <protocol> <port> <descriptiveName> [mode] [scope [addresses]] [profile]
        
where:
In reverse, to delete a firewall exception execute:
netsh firewall delete portopening <protocol> <port>
        
where the <protocol> and <port> have the same meaning as in the previous command.

Example 1:
netsh firewall add portopening TCP 99 "99 tcp port" enable
        
will open the TCP port 99, enable this exception and set it's friendly name to "99 tcp port". The scope is ALL and the profile is CURRENT.

Example 2:
netsh firewall add portopening TCP 99 "99 tcp port" disable
        
will disable the "99 tcp port" exception.

Example 3:
netsh firewall delete portopening TCP 99
        
will delete the exception defined in the first example.

Running processes

Automatic updates - the client

The automatic update client application have the following command line options:

History

Copyright and License

This document is copyrighted (c) 2007 by Calin Radoni. Permission is granted to copy and/or distribute this document.

Disclaimer

No liability for the contents of this document can be accepted. Use the concepts, examples and information at your own risk. There may be errors and inaccuracies that could be damaging to your system. Proceed with caution, the author do not take any responsibility.

All copyrights are held by their respective owners, unless specifically noted otherwise. Use of a term in this document should not be regarded as affecting the validity of any trademark or service mark. Naming of particular products or brands should not be seen as endorsements.


Copyright © 2005 - 2009 Calin Radoni Hosted on http://www.geocities.com/calinradoni Last page modification is 25 June 2007
Hosted by www.Geocities.ws

1