Charora's website  
Home
Wednesday, 08 September 2010
 
 
Who's Online
We have 7 guests online
Polls
Syndicate
How do I get the Username in Windows Services?
Written by Administrator   
Thursday, 24 August 2006

SYMPTOMS
If a Windows Service running under Local System Account, System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() returns NT AUTHOURITY\SYSTEM

You want to get who logged on to the machine?

CAUSE
Windows Service is running under Local System Account. Current user credentials will be NT AUTHOURITY\SYSTEM. You have to query WMI to get current users logged on to the machine.

 


Write Comment
Last Updated ( Tuesday, 06 November 2007 )
Read more...
 
Killing a hang on Windows Service - "Stopping"
Written by Administrator   
Thursday, 31 August 2006
It sometimes happens and it is not a good sign most of the time, you'd like to stop a Windows Service, and when you issue the stop command through the SCM (Service Control Manager) or by using the ServiceProcess classes in the .NET Framework or by other means (net stop, Win32 API), the service remains in the state of "stopping" and never reaches the stopped phase.

It's pretty simple to simulate this behavior by creating a Windows Service in C# (or any .NET language whatsoever) and adding an infinite loop in the Stop method.

The only way to stop the service is by killing the process then.

However, sometimes it is not clear what the process name or ID is (e.g. when you're running a service hosting application that can cope with multiple instances such as SQL Server Notification Services).

The way to do it is as follows:

Go to the command-prompt and query the service (e.g. the SMTP service) by using sc:

sc queryex SMTPSvc
This will give you the following information:
SERVICE_NAME: SMTPSvc
TYPE : 20 WIN32_SHARE_PROCESS
STATE : 4 RUNNING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
PID : 388
FLAGS :

or something like this (the "state" will mention stopping).

You can find the process identifier (PID) over here, so it's pretty easy to kill the associated process either by using the task manager or by using taskkill:

taskkill /PID 388 /F

where the /F flag is to force to kill the process. First try without the flag.

Please be careful when you do this; it is useful for emergencies but you shouldn't use it on a regular basis (use it as a last option to solve the problem or to avoid the need of a reboot in an exceptional situation). It can even be used to stop a service that has the "NOT-STOPPABLE" and/or "IGNORES_SHUTDOWN" flag set (e.g. Terminal Services on a Windows Server 2003 is non-stoppable), at least when it's not hosted in the system process. You can query all this information using the sc command.

More info on sc.exe can be found via http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx.

Write Comment (1 Comments)
Last Updated ( Tuesday, 06 November 2007 )
 
What do I do if SMTP is not showing up in IIS?
Written by Hari Kishan Charora   
Thursday, 31 August 2006
If SMTP is not showing up in the IIS Administrator Console, this either means it is not installed, or not properly recognized by IIS.

If you know that SMTP is installed, from a command prompt, type the following command:
regsvr32 %systemroot%\system32\inetsrv\smtpsnap.dll

This should register the necessary .dll file for IIS to recognize the service.

If SMTP is not installed, you will need to do the following:

1. Click Start -> Settings -> Control Panel -> Add/Remove Programs
2. Click the Add/Remove Windows Components button
3. Select Application Server and click Details.
4. Select Internet Information Services (IIS) and click Details.
5. Check the box for SMTP Service.
Once the installation is complete, open the IIS Manager and you should see the "Default SMTP Virtual Server".


However, by default, the SMTP Server can be connected to from *any* outside source. To restrict this, do the following:

1. Right-click Default SMTP Virtual Server, click Properties.
2. Click the Access tab.
3. Click the Connection button.
4. Change the option to "Only the list below"
5. Click Add, and type the server's IP address or range of IPs into the correct fields.

Write Comment
Last Updated ( Tuesday, 06 November 2007 )
 
<< Start < Prev 1 2 3 Next > End >>

Results 9 - 12 of 12
Google





Lost Password?
No account yet? Register
Archive
Newsflash
Watch your thoughts;
they become words.
Watch your words;
they become actions.
Watch your actions;
they become habits.
Watch your habits;
they become character.
Watch your character;
it becomes your destiny.
-
Frank Outlaw
 
Related Items
Sections
 
Top! Top!