Showing posts with label cmd. Show all posts
Showing posts with label cmd. Show all posts

Thursday, February 7, 2013

Easier way to get to that hosts file

In Windows, there's a hosts file mapping IP addresses to hostnames. For some weird reason, it's in the arbitrary location of c:\windows\system32\drivers\etc\hosts. This kinda reminds me of a Unix/Linux path, with the \etc\hosts. But anyway. That's often too much to type in when just trying to go Start -> Run -> notepad++ hosts. So, use symbolic links :) Something else that is Unix/Linux like, that not many people know exist on Windows:

C:\>mklink hosts c:\windows\system32\drivers\etc\hosts
symbolic link created for hosts <<===>> c:\windows\system32\drivers\etc\hosts

Then you can just say, notepad++ \hosts.

Much easier.

Wednesday, February 1, 2012

Symbolic links and hard links in Windows

A lot of people coming from the Linux world would probably have at some point used symbolic links or soft links, and hard links.

Windows has had shortcuts for a long time, but these are actually files that are used to point to other files, they aren't actually entries in the filesystem that merely reference other files, which is what the links are, meaning that shortcuts take up more space.

A lesser known fact about Windows is that it actually also has symbolic links, hard links, and also with Windows NTFS has the concept of a junction point, which is a hard link for a directory. The differences between them is discussed quite nicely in the post "Windows File Junctions, Symbolic Links and Hard Links".

It also appears that the capability has been around for a while, going back to Windows 2000. With Windows 7 and probably most newer Windows versions these days, there's also a nice command line tool mklink to help with this.

Open up a command line, type mklink /? and then try it out for yourself in a test area, playing with creating new files, linking to them, deleting the original files, seeing how the links are affected, etc.

Disclaimer: If you delete something that wasn't just a pointer to a file, and was the actual file, that's your own fault, don't come looking for me :D

Thursday, June 9, 2011

Starting Windows Services Remotely

Did you know you can use the sc command to start services remotely?

sc \\SERVERNAME start SERVICENAME

e.g.

sc \\test-server query AppFabricCachingService
sc \\test-server start AppFabricCachingService