Monday, January 8, 2007

When did this windows box boot last?

Windoze:


Ever wonder when a windows box was last booted. In linux we can use “who –b” (in most flavours) but what about windows?

Try from the command prompt:

"net statistics workstation ¦ more "

(the for those unfamiliar "¦" is the "pipe" symbol. It is usualy depicted on the keyboard as two vertical lines one above the other)

The output of this command will show the date and time of last startup of windows. (The rest is mostly irrelevant info unless troubleshooting connections to servers)


Linux:

Did you ever have a file with a weird name including control characters which you could not delete? (ab^Hrd[ or something like that) (It could happen when naming a file you do a backspace which is sometimes input as ^H) You can’t do rm ab^Hrd[ because the shell will read part of the name as a control character.

One way to do it is to use the files inode number.

ls –il will show you the inode number of the files in the directory so you find what the inode number of that file is.

then you just type
find . -inum <inode-number>-exec rm -i {} \;
(Of course, replace <inode-number> with the actual inode number)
You will be asked to confirm the deletion and voila. File deleted.

Monday, January 1, 2007

1.Windows:
Remote desktop from a command line or batch file:

You can 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.
. /v:<ipaddress> -- specifies the ip address 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.
· /console—if someone is connected and there are no more valid connections, this will connect to the console session.

For example, to remotely connect to a computer named pinky in a 640 x 480 remote desktop window, you would use the following command:
mstsc /v: pinky /w:640 /h:480

You can type this command line in the Start --> Run dialog box, as well as use it in a batch file.
(This will only work from XP pro and above)

2. Linux:

Resolving netbios name from an ip address
nmblookup –A <ipaddress>
e.g. nmblookup –A 192.168.170.39
will give the netbios name and group (domain) of the windows station with that ip address.