Sunday, February 7, 2016

Useful Window's Commands

I came across below commands which I use regularly, I collected these commands from various blogs and forums and I think you should know below commands

1. Shutdown command:

You can run shutdown the system with below parameters:
  • shutdown -m <machine_name>— shutsdown the remote machine, you can use below parameters with above command
  • -r — restarts
  • shnutdow -s — shutsdown
  • shutdown -l — logoff
  • shutdown -t xx — where xx is number of seconds to wait till shutdown/restart/logoff
  • shutdown -i — gives you a dialog box to fill in what function you want to use
  • shutdown -a — aborts the previous shutdown command
  • shutdown -h — hibernate not for help
  • shutdown -h — hibernate not for help

Additional options:
  • -f — force the selected action
I used to run "shutdown -t 0 -r -f" to forcefully restart the system.

========================================================================


2. To kill process:


TaskKill /F /IM javaw.exe

you can keep any process name instead of javaw.exe, here /F is used for forcefully killing process and IM specifies the image name of the process to be terminated. Use the wildcard (*) to specify all image names. other parameters are below:

/s Computer : Specifies the name or IP address of a remote computer (do not use backslashes). The default is the local computer.

/u Domain \ User : Runs the command with the account permissions of the user specified by User or Domain\User. The default is the permissions of the current logged on user on the computer issuing the command.

/p Password : Specifies the password of the user account that is specified in the /u parameter.

/fi FilterName : Specifies the types of process(es) to include in or exclude from termination. The following are valid filter names, operators, and values.

========================================================================

3. How to install JDK/JRE using command:

Start /wait C:\Kits\jdk-8u73-windows-x64.exe /s INSTALLDIR=C:\apps\Java\jdk-8u73 STATIC=1 WEB_JAVA=0 WEB_JAVA_SECURITY_LEVEL=M SPONSORS=0

=======================================================================

4. Setting environment variable using command:

SETX JAVA_HOME C:\apps\Java\jdk-8u73 /m

========================================================================

5. Go to directory in command prompt:


call cd/d C:\Kits

========================================================================

6. How to get list of files and folders in direcory:

dir /b > filelist.txt 

this will create a file in current directory named filelist.txt

========================================================================

7. How to list all the environment variables:


set > variables.txt

this will list all the variables in variables.txt file.

========================================================================

8. How to map a remote location to a new drive:


Create a bat file("MappingLocation.bat") with below content:

@echo off
if exist Y:\ (
    net use Y: /delete
)
net use Y: \\your\any\remote\location password /user:a_username /persistent:yes

and run that bat file with administrator privilege.

========================================================================


No comments:

Post a Comment