Archive for October, 2008

Find the complexity of code.

October 29, 2008 16 comments

I came across measuring complexity of a piece of code, which is really tricky one. Following is the code,

void function( int n)
while(n > 1)
n = sqrt (n); // assume sqrt returns square root of any number and ignore the complexity of square root

If any one wants to try this do try 🙂 and post your answers.


A small interesting riddle..

October 22, 2008 3 comments

Wandering through the walls of my office I came across this interesting small puzzle, it is stated as:

Question: If it were two hours later it would be half as long until midnight as it would be if it were an hour later What time is it now?

Please post your answers in the comments section..

Launching Executables (showing GUI) from Web Services deployed in IIS

October 16, 2008 8 comments

Recently one of my senior colleague was faced with a problem of launching executables from Web Services hosted in IIS. Following is the problem he was faced with (as is email),

“I am working on a dotNet web service that needs to launch an executable (.exe). I have used System.Diagnostics.Process to launch the process. When I run through VS2005 test environment, web service triggers the executable and its UI is displayed (e.g., launching notepad). But when I deploy the web service under IIS, the web service does launch the process but UI does not appear.

Can someone shed some light on what is happening and suggest a solution to this”

After searching on the internet I found the following solution and it worked fine.

According to Microsoft following are the reasons for this

1.    By default, ASP.NET runs its worker process (Aspnet_wp.exe) with a weak account (the local machine account, which is named ASPNET) which don’t have permission to interact with desktop.
2.    By default, IIS Admin Service won’t allow its application to interact with desktop.

These can be resolved by:

1.    Allowing worker process(ASP.NET) to run in SYSTEM account.
This can be done by editing the machine.config file which is located at (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG. Open the machine.config and find the ProcessModel tag and add the following attributes to it,

userName=”SYSTEM” password=”AutoGenerate”

2.    Enable IIS Admin Service to interact with desktop. To configure this, follow this steps.

a)    Open Control Panel and follow these steps:
For Windows NT: click Services.

For Windows 2000, Windows XP, and .NET Server: click Administrative Tools, and then click Services.
b)    Double-click IIS Admin Service.

c)     On the Log On tab, select the Allow Service to Interact with Desktop check box.

d)    Stop and restart the IIS Admin Service.

3.    Sometimes ASP.NET account does not have enough privileges to access certain WMI namespaces. So to resolve this do the following

a)    Open the Computer Management Microsoft Management Console (MMC) snap-in.
b)    Expand Services and Applications, and then select WMI Control.
c)    Right-click WMI Control, and then click Properties.
d)    In the WMI Control Properties dialog box, click the Security tab.
e)    Expand Root, select CIMV2, and then click Security.
f)    In the Security dialog box, click Advanced.
g)    In the Access Control Settings dialog box, click Add. Select localMachineName\ASPNET, and then click OK.
h)    In the Permission Entry dialog box, make sure that Apply Onto is set to This namespace and subnamespaces.
i)    Make sure that the Allow ‘Enable Account’ and Allow ‘Remote Enable’ check boxes are selected.
j)    Click OK in each dialog box until you return to the WMI Control Properties dialog box.
k)    Repeat steps 5 through 10 for other WMI namespaces that your application will access.
l)    Restart IIS. To do this, run IISRESET from the command line.

Information obtained from:;en-us;317012


Folder Options Diasbled, Task Manager Disabled, Registery Editor Disabled

October 16, 2008 2 comments

This post will be about enabling the folder options, taskmanger and registry editor after they are disabled/not visible. These kind of things are usually consequence of viruses specially “Brontok” trojan which can be deleted by anti-virus. I am writing the solutions, but chances are if these things are caused by virus
really then after restart, these options(folder options, task manager) will again be disabled so use a good anti virus like NOD32 (preferable) or AVG and remove the virus. And then enable
the options as I am telling.

For restoring the folder options do the following.

1. Write regedit at run and open the registery editor.
2. Now locate the following key,

HKEY_CURRENT_ USER\Software\ Microsoft\ Windows\CurrentV ersion\Policies\ Explorer


HKEY_LOCAL_MACHINE\ Software\ Microsoft\ Windows\CurrentV ersion\Policies\ Explorer

And in right-side pane, check whether a DWORD value named NoFolderOptions exists or not? If it exists then either change its value to 0 or delete it.

I hope this resolves your problem of Folder Options in tools menus.
Btw we can access it from Control Panel also.

-If registery editor is also disabled or locked do the following.

1. Write gpedit.msc at run and open the groups policy editor.
2. In the left side tree view locate the User Configuration node and expand it. Now locate the Administrative Templates and expand it also. Now locate System. Now don’t expand it and clicking on it look for the
options in the right view. Locate the item “Prevent access to registry editing tools”. Edit it’s properties and change it to disabled.

If task manager is disabled do the following.

1. Write gpedit.msc at run and open the groups policy editor.
2. In the left side tree view locate the User Configuration node and
expand it. Now locate the Administrative Templates and expand it also.
Now locate System and find Ctrl+Alt+Del Options in it. Left click it once and look for the options in the right side list view. Double Click the option Remove Task Manager and change it’s current setting to Disabled. If it’s already disabled you still have to change the setting to any other value and than change it to Disabled just to refresh it. Be sure to refresh the windows and task manager will be enabled.

I hope this much helps. But I will seriously recommend to scan and clean the system completely with some anti-virus.