Browsing all articles in Windows-related
Jun
25

Automating Windows Process Priority

Author andy18    Category Windows-related     Tags

Recently, I have seen one of the mail server performance I am working on has been dragging down which causes webmail / POP3 to be slow down. It takes me up some times to diagnose on the source of the problems and eventually the drive I/O is the cause of the issue. Well…. upgrading drives by mirroring is pain in ass as it involve down time and I will need to stand by at the data center for the whole night again.

Doing some research on the Net, it cames to my attention that we can prioritize the process running in the Windows background to receive more processing power from the server compare to other processes just like what we have in Linux by seeing on their ‘nice’ status.

We can prioritize the processes through the Windows Task Manager or by using the Sysinternal tools – ProcessExplorer to do the trick. Now question is, how do you reset the processes which constantly being restarted – such as IIS w3wp.exe worker processes after its application pool recycling in Windows 2003? Manually? Wow… you will then need to spend 24 hours sitting in front of your terminal for that.

I have asked around and doing some Googling, and at last, I came to this TechNet article – Modifying Process Startup Options which helps to save my ass from sitting in front the terminal for 24 hours.

Below is the sample scripts. Generally, you will just need to replace the ‘PriorityClass’ and the ‘ProcessName’ ( w3wp.exe ) with your actual process name and voila, you are ready to go. If you want this to be automated, you may setup a cron batch file to auto run it for how often as you need.

Const High = 128
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2″)
Set colProcesses = objWMIService.ExecQuery(“Select * from Win32_Process Where Name = ‘w3wp.exe’”)
For Each objProcess in colProcesses
objProcess.SetPriority(High)
Next

Jun
4

Controlling Windows Server Remote Session

Author andy18    Category Windows-related     Tags

What do you do when you are trying to login to the server via RDP and you are being prompted that the session is full? For me, is kinda of frustrated as I will need to login via another server, open up the Terminal Service Manager to connect to the server to check on which session is left connected without proper log-off.

Well, Windows 2003 server comes with a handy command which allow you to connect as a third session to the server. The third session will be the console session. Here’s the command you may execute from another server and make the connection as a console session:

mstsc /v:servername /console

To check on the remote session via command line, you may use the qwinsta and rwinsta. qwinsta stands for Query WINdows STAtion while rwinsta is Reset WINdows STAtion

To query a remote session:

qwinsta /server:

Example :
qwinsta /server:win2k3

SESSIONNAME USERNAME ID STATE TYPE DEVICE
console 0 Conn wdcon
rdp-tcp 65536 Listen rdpwd
rdp-tcp#2 andy 1 Active rdpwd

To reset a remote session after you have gather the session info, we will use the rwinsta.

rwinsta /server:

As per the example above, we will reset the session owned by “andy” with ID 1.

rwinsta /server:win2k3 1