Wednesday, February 24, 2010

Commands for Command prompt

Type following commands on command window to perform the required task.
By typing "help" on command prompt you can get commands for most common tasks e.g. cd, dir, del, exit, copy etc.
Here I will write down some uncommon commands which will be helpful when working on windows XP using command prompt.

  • hostname: Gives hostname of the machine you are using
  • attrib : Shows or updates Attributes of a file, -h removes hidden attrib from file, while +h adds hidden attrib
  • cacls : Changes the ACLS (security settings) for files and folders, similar to chmod in linux
  • control : Unpublished, use "control userpasswords2"findstr: To find strings, similar to grep in linux
  • gpresult : gets the summary of group policy settings and user settings
  • ipconfig : Shows IP Configuration for your system, use "ipconfig -all " for all settings, "ipconfig /release" for releasing Ip Addresses, "ipconfig /renew" for renewing IP address
  • openfiles : Enables administrator to display a list of open files and folders that have been opened 
  •  reg : A console registry tool to edit registry settings
  • systeminfo : displays system information
  • tasklist: list of all running tasks
  • taskkill: to kill running task
  • taskmgr: To open Task manager from command window
  • tree : Really amazing utility, gives the list of files and folders in tree form , should try at least once.
  • shutdown: Will show help for shutting down the windows XP. This will be helpful when you want to shutdown or restart remote computer.
             shutdown -s : shutdown this computer
             shutdown -r : Restart this computer
             shutdown -m \\computername : Remote computer to shutdown/restart/logoff
             shutdown -i : GUI interface for shutdown

Check this lonk for more detailed info and all other available commands:
Microsoft windows command line tools

Monday, February 22, 2010

Using command prompt on windows mobile 6/6.5

Install windows mobile powertoys to your system then open "C:\Program Files\Windows Mobile Developer Power Toys\PPC_Command_Shell\arm"

Now copy the console.dll to the \windows folder of the device.  Copy cmd.exe and shell.exe to any other location on the device.
Also after doing all this, change the registry in device for "HKEY_LOCAL_MACHINE\Drivers\Console\OutputTo" to 0.

Now open file explorer and run cmd.exe, to close command prompt type "exit" command instead of pressing "X".

Saturday, February 20, 2010

Perl string functions

Here I will mention some Perl string functions:
chop, eval, index, length, substr, crypt are some of the functions which are used in strings in Perl.For more detail on them please refer to this link.


For more detail on Eval function which is very powerful function and which can be used in two forms, either in string or block form. Check this for more information.

Monday, February 15, 2010

Opening .hxt/.hxc type of help files available with platform SDK's from MSDN

These type of files which are made available under help folder and are in Microsoft Help 2.0 format can be opened with "dexplore.exe" viewer. This utility is available at "C:\Program Files\Common Files\Microsoft Shared\Help 9". You can open files by typing the following at a command prompt, or associating it with a
desktop shortcut:

<path>\dexplore.exe /helpcol ms-help://<namespace>

where <namespace> is the name under which the help file has been registered on your system. For example:

"C:\Program Files\Common Files\Microsoft Shared\Help\dexplore.exe"
/helpcol ms-help://MS.xxxxx.xx


You can use either Dave Liske's custom Help 2.0 viewer (http://www.mvps.org/htmlhelpcenter/mshelp2/h2view.html) or Rob Chandler's FAR utility (http://helpware.net/FAR/index.html). These both let you display a list of the registered namespaces and choose the one to initialise. FAR Utility will also work for windows vista while h2view will not work. These utilities are replacement for dexplore.exe and will be simple to use.

So by using correct name space and  creating shortcut you can read the help files.
Even if you want you can use Help 2.0 viewer for viewing your help files as per your namespace.
"File->Open Namespace" Then select namespace and initialise.


If you want to create a shortcut just do right mouse click and say create shortcut. Then give the path or above mentioned command ( ""C:\Program Files\Common Files\Microsoft Shared\Help 9\dexplore.exe" /helpcol ms-help://MS.MSDNQTR.v90.en" ) and give the name for shortcut and you are done.

Monday, February 8, 2010

Environmental Variables

Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. these have been used for long in operating systems and are present in Unix, DOS and Windows environment.

Microsoft's definitions:

Environment variables are strings that contain information such as drive, path, or file name. They control the behavior of various programs. For example, the TEMP environment variable specifies the location in which programs place temporary files.

 Examples of environment variables include:
  • PATH - lists directories the shell searches, for the commands the user may type without having to provide the full path.
  • HOME (Unix-like) and userprofile (Microsoft Windows) - indicate where a user's home directory is located in the file system.
Shell scripts and batch files use environment variables to communicate data and preferences to child processes. They can also be used to store temporary values for reference later in the script, although in Unix other variables are usually used for this.

Examples of DOS Env Variables:
%ERRORLEVEL% : This variable points to the current error level. If there was an error in the previous command, this is what you need to check against to find out about that.
%PATH% : This variable contains a semicolon-delimited list of directories in which the command interpreter will search for executable files. Equivalent to the Unix $PATH variable (although note that PATH on Windows additionally performs the same task as LD_LIBRARY_PATH on Unix-like systems). Note that %PATH% can also be set like this PATH=c:\dos; where SET isn't required.
%TEMP% and %TMP% : These variables contain the path to the directory where temporary files should be stored.
Examples of UNIX ENV Variables:
$PATH : Contains a colon-separated list of directories that the shell searches for commands that do not contain a slash in their name (commands with slashes are interpreted as file names to execute, and the shell attempts to execute the files directly).
$HOME : Contains the location of the user's home directory. Although the current user's home directory can also be found out through the C functions getpwuid and getuid, $HOME is often used for convenience in various shell scripts (and other contexts). Using the environment variable also gives the user the possibility to point to an other directory.
$PWD : This variable points to the current directory. Equivalent to the output of the command pwd when called without arguments.
$TZ : Refers to Time zone. It can be in several formats, either specifying the timezone itself or referencing a file (in /usr/share/zoneinfo).
Example from Microsoft Windows: Case Insensitive
%CD% : This variable points to the current directory. Equivalent to the output of the command cd when called without arguments.
%DATE% : This variable expands to the current date. The date is displayed according to the current user's date format preferences. For more info on how to set date variable refer %DATE%
 
%RANDOM% : This variable returns a random number between 0 and 32767
%TIME% : This variable points to the current time. The time is displayed according to the current user's time format preferences.
 
Reference: 
Default values of Environment Variable on Microsoft windows
Further Related Study:
List of UNIX Utilities
 

What is difference between %cd% and %~dp0

%cd% is available either to a batch file or at the command prompt and expands to the drive letter and path of the current directory (which can change by using the CD command)

%~dp0 is only available within a batch file and expands to the drive letter and path in which that batch file is located (which cannot change). It is obtained from %0 which is the batch file's name.

An experiment like the following shows the difference

Here is E:\dirpath.bat:

echo this is %%cd%%  %cd%
echo this is %%~dp0 %~dp0

Run it from C:\ and this is what you see

Code:
C:\>E:\dirpath.bat
this is %cd%  C:\
this is %~dp0 E:\

Wednesday, February 3, 2010

Using Remote desktop from command line

Remote desktop allows you to configure and connect to another computer running Windows XP Pro.
Host machine must also have the Remote Desktop Connection client software installed. The  remote computer which is known as the client and Host both should be part of a corporate network in which Remote Desktop connections are permitted.

The Windows XP remote desktop connection dialog box provides you with everything that you need to configure and connect to another computer running Windows XP Pro. You can use the Save As button on the Connection Settings panel to save all your connection settings as an RDP file. Then, you can launch and connect to a remote computer simply by double-clicking the RDP file.


You can also script a remote desktop connection, as Windows XP's remote desktop connection has an executable file that can accept command line parameters and be run from a batch file. The remote desktop connection executable file is MSTSC.EXE, and the following are some of the most common parameters:

/v:<computername>--specifies the name of the computer to connect to.

/f--starts the connection in a full screen.

/w:<width>--specifies the width of the remote desktop screen.

/h:<height>--specifies the height of the remote desktop screen.

For example, to remotely connect to a computer named System in a 640 x 480 remote desktop screen, you would use the following command:

mstsc /v: System /w:640 /h:480

You can type this command line in the Run dialog box, as well as use it in a batch file.

Ref:
WindowsXP: Using mobility
Remote desktop FAQ