Command/Powershell script to reset a network adapter

You can use WMI from within PowerShell to accomplish this. Assuming there is a network adapter who’s device name has Wireless in it, the series of commands might look something like the following: $adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like “*Wireless*”} $adaptor.Disable() $adaptor.Enable() Remember, if you’re running this with Window’s Vista, you may … Read more

How can i see the assembly version of a .NET assembly in Windows Vista and newer (WIndows 7, 2008)?

No. Not from explorer. It is an intentional move by Microsoft (although I dislike it). You can from powershell though: [Reflection.AssemblyName]::GetAssemblyName(‘full-path-to\xxxx.dll’).Version Also if file version is not explicitly set it will default to assembly version. Here is some info: http://all-things-pure.blogspot.com/2009/09/assembly-version-file-version-product.html

Debugging javascript in Safari for Windows

Well, apart from the Error Console that can be opened from the Develop menu (which in turn can be enabled in (Prefences / Advanced / Show Develop menu in menu bar) there aren’t many javascript debugging options in Safari AFAIK. Still, the error console is quite useful as it shows javascript errors and also lets … Read more

How to programmatically derive Windows Downloads folder “%USERPROFILE%/Downloads”?

Yes it is special, discovering the name of this folder didn’t become possible until Vista. .NET still needs to support prior operating systems. You can pinvoke SHGetKnownFolderPath() to bypass this limitation, like this: using System.Runtime.InteropServices; … public static string GetDownloadsPath() { if (Environment.OSVersion.Version.Major < 6) throw new NotSupportedException(); IntPtr pathPtr = IntPtr.Zero; try { SHGetKnownFolderPath(ref … Read more

What directories do the different Application SpecialFolders point to in WindowsXP and Windows Vista

There’s no single answer to that. In fact, that’s precisely why these “SpecialFolder”s are defined. You use those instead of a hardcoded path. Environment.SpecialFolder.ApplicationData is the most common one. This folder holds per-user, non-temporary application-specific data, other than user documents. A common example would be a settings or configuration file. Environment.SpecialFolder.CommonApplicationData is similar, but shared … Read more

Active Directory – Check username / password

If you’re using .net 3.5 use this code instead. To authenticate a user: PrincipalContext adContext = new PrincipalContext(ContextType.Domain); using (adContext) { return adContext.ValidateCredentials(UserName, Password); } If you need to find the user to R/W attributes to the object do this: PrincipalContext context = new PrincipalContext(ContextType.Domain); UserPrincipal foundUser = UserPrincipal.FindByIdentity(context, “jdoe”); This is using the System.DirectoryServices.AccountManagement … Read more

Avoid “program stopped working” in C#/.NET

The JIT debugger popup occurs when there’s an unhandled exception. That is, an exception tunnels all the way up the stack to the root of any thread in the runtime. To avoid this, you can handle the AppDomain.CurrentDomain.UnhandledException event and just call Environment.Exit(1) to exit gracefully. This will handle all exceptions on all threads within … Read more

Why do files get placed in “C:\Users\AppData\Local\VirtualStore\Program Files(x86)”?

An application that is not running with raised privileges should does not have access to the Program Files and Program Files (x86) directories. This is good for safety. In addition, in most cases when a developer tells his program to save data in the Program Files folder, for example, program settings, he has completely forgotten … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)