Showing posts with label Command line. Show all posts
Showing posts with label Command line. Show all posts

Sunday, 27 September 2009

How to create a folder with a MS-DOS command

To create a folder/directory using a DOS command, do the following :

Open up a command window i.e. Winkey + R and type cmd into the field and press Enter.
Type : md c:\Testfolder and press Enter

That's it, you will now have a folder called 'Testfolder' on your C drive !

How to merge multiple .csv files into one .txt file using command line

Create a folder on your c: drive called 'All csv files' and place all of your .csv files inside.
Open notepad and add the text below
cd C:\All csv files

copy *.csv Merged.txt

Save the text file and changed its extension to .bat 'merge.bat'.
Double click the file and you will see that a txt file is created in the C:\All csv files folder called 'Merged.txt' with all your consolidated information inside !.

Disable a user account using command line

Access your domain contoller and type the following format to disable your user :

dsmod user "cn=Joe Bloggs, ou=IT Admins, dc= Your Domain name , dc=com" -disabled yes

Check if user account is active using command line

Access your domain contoller and type the following format to check if the user is active :

NET USER jbloggs /DOMAIN | FIND /I "Account active"

Find the name of members within a group using command line

Access your domain contoller and type the following format to find the members of a group :

dsget group "cn=IT guys, ou=IT admins, dc= Your Domain name , dc=com" -members

Delete a user in Active Directory using command line

Access your domain contoller and type the following format to delete your user :

dsrm "cn=Joe Bloggs, ou=IT Admins, dc= Your Domain name , dc=com"

Add a user in Active Directory using command line

Access your domain contoller and type the following format to add your user :

dsadd user "cn=Joe Bloggs, ou=IT Admins, dc= Your Domain name , dc=com" -samid joebloggs -upn info@YourDomain.com -fn Joe -ln Bloggs -display "Joe Bloggs" -pwd Pa$$w0rd -desc "Systems Administrator"

*ou = is the name of Organisational Unit you will be adding the user to.

How to start and stop a service using command line

This method of starting and stopping a service applies to all Windows based operating systems e.g. Windows 2000, XP, Vista and Windows Server 2000/2003.

The first thing you will have to know is the name of the service you want to stop or start. You can find this by going to the services list :

1.Winkey + r
2. Type 'services.msc'
3. Locate the service you wish to start/stop and righ click>properties
4. The Service name is shown at the top on the general tab.

For my example i am going to use Internet Information Server (IIS) as the service i wish to stop. It's service name is 'w3svc'. So once you have the name then perform the following :

1. Winkey + r (or start menu and then click 'Run')
2. Type 'cmd' and press enter to bring up a command prompt.
3. Type Net Start or Net Stop (depending on what action you wish to perform) and then the service name e.g. 'Net stop w3svc'. Press enter.
4. In the above instance the command prompt window would show the messages "The World Wide Web Publishing service is stopping." and "The World Wide Web Publishing service was stopped successfully".

So, to start the service back up i would just use the Net start command.

Saturday, 26 September 2009

How to see the names of all computers on your network with a single command

Open up a command window i.e. Winkey + R and type 'cmd' into the field and press Enter.
Type : Net View and press Enter

How to restart/shutdown a PC remotely using command line

This question came about when I was on my test server trying to install some software remotely, on a client laptop. I wanted to apply some changes and needed to reboot so rather than rolling the two feet to my laptop I thought "hmmm, how can I do this from here". And here's the answer ...........

Open up a run window (Winkey + R)
Type 'cmd' to open a command prompt

Type :

shutdown m \\computername -s -t : 60 (This will shutdown the PC in question after 60 seconds).

shutdown m \\computername -r -t: 60 (This will restart the PC in question after 60 seconds).

shutdown m \\computername -r -t: 0 (This will shutdown the PC immediately).

shutdown m \\computername -a (This will abort the shutdown once it is counting down)

This code can also be added to a batch file to shutdown multiple PCs all at once !