Where is the Hosts file location in Windows 8?

The Hosts files is a file that allows you to override the DNS lookups for specific domains.

Say you want to test your application that has brianseekford.com hardcoded but you actually want to run it against your local computer IP 127.0.0.1

You edit the hosts file and simply add the entry:

127.0.0.1      brianseekford.com

ALL dns lookups will now return 127.0.0.1 when looking for that domain, so your browsers etc will now all redirect. It was also the old school way to do ad blocking, put in a domain you never want to resolve. i.e. ads.joe.com

Anyway, now that you know what it does, this is where to find it:

C:\Windows\System32\drivers\etc

Remember, open notepad as Administrator FIRST, otherwise you wont be able to save.

 

Are you tired of changing your password at your company?

Some company’s require you to change your password all the time. This is probably a good idea from a security perspective, but can also be really annoying. I wrote a proof of concept application that you can use that will change your password for you and revert it back to your original. Basically, a way to keep your existing password but make the domain computer think you just changed it.

NOTE: If this violates your company policy, don’t do this. I accept no liability for your actions. This program is simply showing you that it can be done, and quite easily.

Just run it, type in your current password and it will reset the timer on your password.

 

How does it work? It will keep changing your password by appending a new letter of the alphabet to your original password over and over. a,b,c. etc. This is to purge the history of your original password. The program then sets it back to your original. It takes about 10 seconds to run.

Note, it uses windows APIs and your credentials aren’t sent anywhere. Disassemble the app if you want to verify it.

 Download Keep My Password Here

Happy coding!

Detect Windows/Operating System Version in C# .NET

Are you looking for a way to detect which OS you are running on in your .NET application? I know I had to so that I could implement workarounds that were OS specific.

Here is a simple function to get the name. You can use this as an idea of how to pick the exact version you are on.

Please don’t be one of those morons that uses this function then does a string comparison on the return. Use common sense and extract the logic from this to get what you need.

I better not see any code out there like

if(GetOSVersionName() == "Windows 98"){Do stupid stuff here}

Yes, it would technically work, so I have no doubt it will be implemented that way by some of you. Religious debate? Probably.

[csharp]
 public string GetOSVersionName()
        {
            string strVersion = "Unknown";
            switch (Environment.OSVersion.Platform)
            {
                case PlatformID.Win32S:
                    return "Windows 3.1";
                case PlatformID.Win32Windows:
                    switch (Environment.OSVersion.Version.Minor)
                    {
                        case 0:
                            return "Windows 95";
                        case 10:
                            if (Environment.OSVersion.Version.Revision.ToString() == "2222A")
                            {
                                return "Windows 98 Second Edition";
                            }
                            else
                                return "Windows 98";
                        case 90:
                            return "Windows ME";
                    }
                    break;
                case PlatformID.Win32NT:
                    switch (Environment.OSVersion.Version.Major)
                    {
                        case 3:
                            return "Windows NT 3.51";
                        case 4:
                            return "Windows NT 4.0";
                        case 5:
                            switch (Environment.OSVersion.Version.Minor)
                            {
                                case 0:
                                    return "Windows 2000";
                                case 1:
                                    return "Windows XP";
                                case 2:
                                    return "Windows 2003";
                            }
                            break;
                        case 6:
                            switch (Environment.OSVersion.Version.Minor)
                            {
                                case 0:
                                    return "Windows Vista";
                                case 1:
                                    return "Windows 2008";
                                case 2:
                                    return "Windows 7";
                            }
                            break;
                    }
                    break;
                case PlatformID.WinCE:
                    return "Windows CE";
                case PlatformID.Unix:
                    return "Unix";
            }
            return strVersion;
        }
[/csharp]

Happy Coding!

Windows 7 is officially bad ass…………

I got a virus on my Windows Vista machine that caused it to run slower than all holy hell. I decided, well, now must be the time to upgrade my OS. No one ever wants to go through the new OS nightmare of having to reinstall every program they use. Especially not a guy in the IT field that uses a whole lot more than just Office.

So, I went full out and put on Windows 7 64-bit. Oh yeah. I finally get all 4 gigs of my ram. I expected the OS to be pretty much Vista with a new name.

Luckily, its not. I have only had it installed for about a day now but I see all sorts of little changes that make my experience SOOOO much better.

The themes are really cool. The desktop background rotates a nice image  every hour or so. I definitely like the variety, but thats not my big happy change.

The UAC is a lot more friendly than it used to be. I like the prompts as it make me feel a bit in control, but in Vista I disabled UAC altogether because nothing worked when it was on. Windows 7, not a problem. I run Visual Studio 2008 and don’t have any of the Vista issues I had.

The biggest thing I found I like so far is the taskbar. I am not only able to “pin” my programs to it, which is a great timesaver, but I can pin my documents to the program as well. I open and close the same 4 documents all the time. Now, its easy to pop into the word icon and go right to my document. Great time saver.

The other major timesaver I use is the ability to see all the windows for a process when I click on the taskbar icon. It is so much easier to figure out what IE window I want to go to or explorer folder when I can see the image of it at a glance. 

Windows 7 gets my vote as a great new OS for productivity. Vista is a smelly pile of crap once you get used to the new Windows.

XP decides opening new windows is no fun….

I happen to do a lot of multi-tasking. I have 4 copies of Visual Studio 2008 open with Management Studio for 2008 open plus a number of different browser windows and explorer folders. I eventually run into this invisible wall where no new windows get created. No new tabs, links stop working, applications won’t launch etc. Whats the temporary fix? I start closing windows and boom, I can now open up new ones.

It seems Windows has a very unfriendly bouncer that says the club is full and until people decide to leave, no one gets in.

I get these awesome event log entries:

Application popup: ftpit.exe – Application Error : The application failed to initialize properly (0xc0000142). Click on OK to terminate the application.

So, what is the fix? Disclaimer, changes to your system can cause inoperability if done improperly. Advice is without warranty 🙂

The system seems to allocate memory to the desktop heap by certain system boot parameters. All handles GDI object and User objects seem to use this 48mb desktop heap.

The solution I tried and sitting around to see if works well is to change these boot params.

I am changing the reg key:

HKEY_LOCAL_MACHINESystemCurrentControlSetControlSession ManagerSubSystemsWindows
From : %SystemRoot%system32csrss.exe ObjectDirectory=Windows SharedSection=1024,3072,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16
To: %SystemRoot%system32csrss.exe ObjectDirectory=Windows SharedSection=1024,8192,2048 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16
You can read more about it on MSDN.
If this solves your problem, let me know.

Joining to a domain and getting error code 1355

So…I was trying to add a computer to the domain today, a VM image, and continually got the error code 1355. What was seemingly a confounding issue turned out to be just a can’t find domain controller issue.

I changed the VM image to use bridged (direct connect) and reset the connection in the machine to reconnect and voila! The computer successfully connected.