Controller action methods and new parameters

ASP.NET MVC | Posted by p_lider May 11th, 2014

When you change a controller’s action method by adding a new parameter make sure that the parameter has a default value specified or is of Nullable type. Not doing so will render the action method unusable if called without the newly added parameter – the IIS will be returning 404 HTTP error code without throwing any other exception or error message rendering the debugging of this situation very hard.

Cloning Windows 8 or Windows 8.1 on UEFI/GPT disk configuration

Operating Systems, Windows 8 | Posted by p_lider January 6th, 2014

Recently I bought a new SSD disk for my new laptop. I didn’t want to install the whole operating system from scratch so I decided to just clone an existing operating system to this new disk. In the past I never worked with GPT formatted disk, so I thought that the process of cloning disk will be similar – and that was a bad assumption.

When I looked how the existing original disk was partitioned to my surprise I saw 5 (that’s right – five) partitions. They were marked as follows:

  1. OEM Partition (1023 MB in size) – now I know that such partition contains Windows Recovery Environment
  2. EFI System Partition called ESP (360MB in size) – it is similar to “Active Partition” known in MBR formatted disks, the UEFI looks for boot manager only on partitions of this type
  3. Boot, Primary partition – the first partition which is actually seen in My Computer as C: drive and it contains Windows system files
  4. Primary Partition – the second and biggest partition which contains my other data (seen as drive D: in My Computer)
  5. OEM Partition (labeled “Recovery Image”) – contains recovery image which was created by laptop manufacturer

 

So the biggest question was – which of those partitions should I clone to the new disk and how to do this? In the past, when working with Windows XP and MBR formatted disks the only partition I had to clone was the partition, that contained the Windows system files (in the above scenario it would be number 3). But here it was not the case. The files that are required for the system to boot lie on the partition number 2. So after checking what these all 5 partitions contain I went to conclusion, that I need to clone at least 2 partitions:

  • EFI System Partition (partition number 2 in my case)
  • Boot, Primary Partition (partition number 3 in my case)

 

When I finally identified which partitions I should clone, I then needed to chose a tool to actually clone them. In the past I was using SelfImage to do such work, however for some reason this program has problems with GPT disks. So then I used a good old tool, known from UNIX like systems, called DD. There is a port of this wonderful tool for Windows called “DD for Windows“.

Having all my questions answered I started to work with cloning the partitions. This is the procedure I followed to successfully clone my current system to a new SSD disk:

  1. Create 2 partitions on new disk (EFI System partition and Windows Primary partition)
    		
    select disk <destination_disk_number>
    clean
    convert gpt
    create partition efi size=SOURCE_EFI_PARTITION_SIZE
    format quick fs=fat32 label="SYSTEM"
    create partition primary
    format quick fs=ntfs label="Windows"
    exit
  2. Using DD program (or any other partition cloning program) copy all contents of source EFI System partition and Windows Primary partition to the new, just created, partitions.

    WARNING: cloning of the partition which contains Windows system files must be done when the system contained on it is not running – I did that using Win7PE DVD, but you could do this using for example any live Linux distribution.

  3. After cloning is complete you have to assign a letter to both cloned partitions (assume that ESP will be mounted to S, and Windows partition will be mounted to W). Although assigning a letter to cloned Windows partition is not a big deal (you can do this from Disk Management), then assigning the letter to the cloned ESP is not so easy – you cannot do this from Disk Management snap-in. To assign a drive letter to ESP partition you have to do this using DISKPART utility:
    		
    select disk <destination_disk_number>
    select partition <index_of_cloned_esp_partition>
    assign letter=s
    exit
  4. Process of cloning the ESP partition makes one nasty thing to boot manager contained on it – it invalidates the “device” and “osdevice” variables stored within its configuration. So to make the cloned system bootable without BSOD, after the letter to cloned partitions are assigned, you have to edit boot manager configuration contained on ESP partition and properly set the “device” and “osdevice” variables so they point to cloned Windows partition. To do so use the BCDEDIT utility (I assumed below that you mounted cloned ESP partition under S letter and cloned Windows partition was mounted under letter W):
    		
    bcdedit /store s:\boot\bcd /set {default} device partition=W:
    bcdedit /store s:\boot\bcd /set {default} osdevice partition=W:

    WARNING: It is very important to use here a cloned ESP and Windows partitions (mounted under letter S and W), not the original ones.

  5. Done – you should now have a working, cloned Windows 8 system on a new disk.

Windows registry autorun locations

Operating Systems, Windows 7, Windows 8, Windows Explorer, Windows Server 2003, Windows Server 2008 and 2008 R2, Windows XP | Posted by p_lider November 17th, 2013

Many times people ask me to check their computers for malware or for the reason it is working slow. The first thing I do is to check all programs that automatically start with windows. Normally I remember 4 or 5 locations in registry where to look for such programs and almost all the time I must search the internet for another ones. That made me to write this post, which will allow me to always have the full (or almost full) list about the registry locations for auto startup purpose in one place.

In the below table I described all of the registry locations I know which programs are using to start automatically with Windows:

No.

Registry Location (blue ones are present in 64bit OS only)

Description

1

HKML\Software\Microsoft\Windows\CurrentVersion\Run\

HKML\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Run\

All values
under this key are executed when any user logs in.

2

HKML\Software\Microsoft\Windows\CurrentVersion\RunOnce\

HKML\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\RunOnce\

All values
under this key are executed when any user logs in. After execution
the values are being deleted.

3

HKML\Software\Microsoft\Windows\CurrentVersion\RunServices\

HKML\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\RunServices\

All values
under this key are executed as services when any user logs in.

4

HKML\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce\

HKML\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\RunServicesOnce\

All values
under this key are executed as services when any user logs in.
After execution the values are being deleted.

5

HKCU\Software\Microsoft\Windows\CurrentVersion\Run\

All values
under this key are executed when current user logs in.

6

HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce\

All values
under this key are executed when current user logs in. After
execution the values are being deleted.

7

HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce\Setup\

Used only by
setup. A progress bar is being displayed.

8

HKU\.Default\Software\Microsoft\Windows\CurrentVersion\Run\

Same as 5 but
applies to LOCAL SYSTEM user only.

9

HKU\.Default\Software\Microsoft\Windows\CurrentVersion\RunOnce\

Same as 6 but
applies to LOCAL SYSTEM user only.

10

HKLM\Software\Microsoft\Windows
NT\CurrentVersion\Winlogon\

Shell”
and „Userinit” values contain file names separated
with comma which are executed when any user logs in.

11

HKCU\Software\Microsoft\Windows
NT\CurrentVersion\Winlogon\

Shell”
and „Userinit” values contain file names separated
with comma which are executed when current user logs in.

12

HKLM\Software\Microsoft\Active
Setup\Installed Components\

HKLM\Software\Wow6432Node\Microsoft\Active
Setup\Installed Components\

All subkeys
are evaluated for execution when any user logs in. The “StubPath”
value under each subkey describes the program being run.

13

HKCU\Control
Panel\Desktop

SCRNSAVE.EXE”
value is executed when screen saver is being displayed for current
user.

14

HKLM\System\CurrentControlSet\Control\Session
Manager\

The
„BootExecute” value is being executed at boot time.

15

HKLM\System\Control\WOW\cmdline

Value is
executed when 16 bit application is being run for all users.

16

HKLM\System\Control\WOW\wowcmdline

Value is
executed when 16 bit DOS application is being run for all users.

17

HKLM\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad\

HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\ ShellServiceObjectDelayLoad\

Values
contains GUID for COM library which is being run after explorer
finished loading.

18

HKCU\Software\Microsoft\Windows
NT\CurrentVersion\Windows\

The „run”
and „load” values are executed when current user logs
in.

19

HKLM\Software\Microsoft\Windows
NT\CurrentVersion\Windows\AppInit_DLLs

HKLM\Software\Wow6432Node\Microsoft\Windows
NT\CurrentVersion\Windows\AppInit_DLLs

AppInit_DLLs
value contains dll file names separated with comma which are being
loaded into every process being run in the system.

IMPORTANT:
Very dangerous entry used by many malware programs.

20

HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\run\

Same as 5.
Normally values are named here as numbers starting from „1”.

21

HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\run\

Same as 1.
Normally values are named here as numbers starting from „1”.

Some information in the above table has been taken from this forum: Registry AutoStart Locations

Decommissioning first Exchange 2003 server together with first AG

MS Exchange | Posted by p_lider March 24th, 2013

Recently I had to decommission the first Exchange 2003 server in our company. Our exchange organization had 2 Exchange 2003 SP2 servers and 2 Administrative Groups (each server in a separate AG). When searching the internet for help in doing that I have found the following article – http://support.microsoft.com/kb/822931.

This article describes almost everything what you should do except the following:

  1. What to do with “schema-root”, “OWAScratch{GUID}” and “StoreEvents{GUID}” system folders.
  2. How to delete the first AG when removing the last server from it.

 

Ad. 1. It is best to rehome mentioned system folders to the other server as you did with the OAB folders and others, so their content is removed from the server being decommissioned but stays on the other one. This would be the best way to get rid of them from the “Public Folder store” of the retiring server.

This is in contrast to simply deleting the folders – I noticed that deleting these folders can lead to strange behavior: they structure is being regenerated by the Exchange after decommissioning the first server however they do not have a replica so they cannot be used. This is not preventing the public folders from working fine, however this causes errors when looking at them using “Exchange System Manager”. I do not know if this can lead to some other, serious problems but seeing an errors in ESM is not a good sign I think.

When there are no mailboxes and public folder instances left on the decommissioned server and other steps mentioned in Microsoft’s article are already done then you can remove the “Public Folder Store” and “Mailbox Store” from it.

 

Ad. 2 If you want to remove whole Administrative Group which will be empty after decommissioning the server, then before uninstalling the Microsoft Exchange from the server follow these steps:

  1. Move the “Public Folders” tree to the other AG if it exists in the current AG being removed.
  2. Remove all the connectors from the routing groups stored within this AG and all connectors from other routing groups in other AGs which were connected to the routing groups in the AG being removed.
  3. Uninstall the Microsoft Exchange from the server being decommissioned in this group.
  4. Remove all routing groups from the AG.
  5. Remove all containers from the AG.
  6. Remove the AG.

Steps 1,2,4,5,6 are best to be performed using ESM on other Exchange server (anyone which is not being decommisioned).

RAID lost after replacing a video card

Hardware | Posted by p_lider January 10th, 2013

Recently I went into a very, very strange problem. I have a RAID5 disk array in my home PC based on SB8xx AMD controller. Recently I bought a brand new graphics card to my computer. After replacing my old one to my horror I noticed, that BIOS does not see any of my hard drives plugged into my built-in RAID controller on my ASUS motherboard. I was shocked, that replacing a video card can lead to such problems with my RAID (what the hell?). I would never suspect that I can lost my hard drives after replacing a video card…

Fortunately it was not as bad as I firstly thought. The raid was not seen by the BIOS itself, thats true, however the operating system did see my RAID array without any problems – like nothing happened. I only lost the boot availability from any hard drives which were connected to my RAID controller.

First thing I did was to change my system hard drive mode from RAID to IDE in system BIOS. That allowed me to boot my system and after that the system saw my RAID array without any problems. That was a relief, because I thought that I have lost my array together with the data contained within.

But that was no solution to me, because the system hard drive operating in IDE mode works noticeably slower and I did not buy an expensive video card to slow down my computer!

Then I started thinking what could have caused such strange behavior. I tried upgrading the BIOS but that did nothing. Then I recalled, that the system BIOS is mapping boot roms of hardware within a special memory, called a Conventional Memory which is always 640KB in size. So maybe the system BIOS has wrongly mapped the roms and not all of them fit into 640KB? And that was it! Disabling some built-in roms (in my case I disabled buil-in IDE BIOS ROM because I do not boot from IDE devices normally) did the trick – the system BIOS started to see my RAID array again. Uff.

So if anyone would ever go into similar problems after replacing a video card – to workaround the issue you will have to disable some unused built-in roms in BIOS setup to allow RAID BOOT ROM to fit into conventional memory and be seen by the system BIOS.

AMD SB8XX RAID + Windows 8 = BSOD

Hardware, Windows 8 | Posted by p_lider December 18th, 2012

If you are using RAID feature of AMD SB8XX chipsets you can encounter a lot of BSODs when using Windows 8 even during system installation. This is caused by a buggy amdsbs.sys driver which is integrated into Windows 8 distribution media.

To be able to successfully install Windows 8 in such situation you must set SATA controller mode of system hard disk to IDE for the time of system installation. After the system is installed first thing to do is to install the newest RAID driver from AMD site and disable the buggy amdsbs.sys driver in the registry (without disabling it you will still sporadically encounter BSODs even though the newer and bug free driver from AMD is installed). To completely disable the buggy driver you have to perform the following steps:

  1. Open Registry Editor
  2. Navigate to the “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\amdsbs” key.
  3. In the right pane find “Start” parameter, double click it and set its value to 4.
  4. Close the Registry Editor and reboot the system.

After installing the newest RAID driver and disabling the buggy one, you can set back the SATA mode of your disks to RAID and the Windows will be working stable now.

PHP and IIS7 using FastCGI – HTTP 500 error

IIS | Posted by p_lider December 18th, 2012

When you install a php into IIS7 and try to execute phpinfo() script you can get an HTTP 500 Internal Server Error message. The most probably cause of this is that php-cgi.exe program is writing some text to stderr. By default IIS7 displays an HTTP 500 error message when it detects such behavior even, when the CGI displayed only a warning message on stderr. To avoid this problem you have to change default error handling for FastCGI in IIS7.

To do this follow the following steps:

  1. Start IIS Manager
  2. Click on <server name> and then in the right pane go to “FastCGI Settings”.
  3. Right click on php-cgi.exe file and choose “Edit…”.
  4. Set the “Standard error mode” option to “IgnoreAndReturn200” value.
  5. Click OK and close IIS Manager.

After performing mentioned steps you shall no longer see HTTP 500 error messages in the browser.

How to prevent reinstalling Windows after changing motherboard, disk controller or processor.

Windows Server 2003, Windows XP | Posted by p_lider October 28th, 2011

In most cases, when we replace the motherboard with or without a new processor in the computer the previously installed system will not boot – probably we will end with BSOD. After that most people will go and reinstall the previously installed operating system because they think there is no other option to resurrect the old one. Well, this is not true. Here I want to tell what steps (without getting to the very details) you must do to resurrect previously installed system.

But first let think why the old os cannot successfully boot on the new hardware. The problem lies in two places (or at least in one of them). First is the controller of the system disk – if the controller in the new motherboard comes from other vendor or is simply incompatible with the old controller (for examle the old one was Intel IDE and the new is VIA IDE), then the os does not have the right device driver for it and as the result it cannot access the hard drive during boot resulting in BSOD. The second lies in the processor architecture (but only if the new processor is from other vendor, for example the old one was from Intel and the new one comes from AMD).

To cope with the problem with device driver for disk controller you have to have a Live CD or bootable USB flash (with BartPE, VistaPE, etc.) in which you can access the system partition and the registry of the installed system. You will have then manually place the right driver for the new disk controller in the “%systemroot%\system32\drivers” folder and manually add or edit the registry to make the driver being loaded with the system (the drivers are being represented as services in the following registry key: HKLM\System\CurrentControlSet\Services).

When you will be fine with the driver for the hard disk controller, then you need to ensure that the IntelPPM service is disabled  (in the registry the start value must be set to 4). Without disabling it, when the new processor comes not from Intel, you will end up with BSOD as well.

This is not a detailed explanation of what to do exactly but it shows the way you shall go if you don’t want to reinstall the whole operating system after changing your hardware like motherboard, disk controller or processor.

Reading exit code value when executing bat file from other bat file.

Windows Batch Scripting | Posted by p_lider May 6th, 2011

If you have to execute a bat file from other bat file, you normally use CALL command to achieve your goal. Everything works fine until you want to retrieve exit code of called bat file (the %ERRORLEVEL% environmental variable) when you executed the CALL command within IF clause.  The problem is that that the %ERRORLEVEL% variable will not change its value after calling other bat file until we leave the  IF clause!

So to sum up – always read %ERRORLEVEL% variable outside any IF clause. Not doing so will cause wrong exit code to be retrieved. This is very strange behavior which made me to spend all day searching what is wrong with my BAT files not working.

Restoring URL autocomplete feature in IE.

Internet Explorer | Posted by p_lider December 29th, 2010

I recently faced strange problem with IE8 browser. The URL autocomplete feature suddenly stopped working. I searched the internet deeply to find the fix for this problem with completely no luck. Analyzing how the IE8 browser works I found, that it is looking for a COM object with class ID {80A3E9B0-A246-11D3-BB8C-0090272FA362} when trying to autocomplete URLs. I then googled for the library which contains the object with mentioned Class ID and found that it is “langwrbk.dll“. Having that in mind fixing the problem was as easy as executing one command:

regsvr32 langwrbk.dll

This worked in IE8 browser, however I am almost sure it will work in other versions of IE as well.