“StartServiceCtrlDispatcher failed (error 6)” is returned from attempting to start SQL Server Agent and “System.NullReferenceException: Object reference not set to an instance of an object.” is returned when attempting to start SQL Server Agent in SQL Server Management Studio

System Requirements:

  • Microsoft SQL Server 2008

The Problem:

It’s another instance of a new SQL Server installation on a newly installed Windows Server system that refuses to do what it is supposed to do. It seems to me that this is the rule rather than the exception, but I digress.

If you pull up a command prompt and attempt to manually start the SQL Server Agent process e.g.

"F:\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Binn\SQLAGENT.EXE" -i MSSQLSERVER

You will receive

StartServiceCtrlDispatcher failed (error 6)

Similarly, if you attempt to start the SQL Server Agent inside SQL Server Management Studio you will receive the ubiquitous

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.

Server stack trace:
at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ObjectExplorer.FindObjectExplorerFrame()
at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ObjectExplorer.GetObjectExplorer(Boolean activateWindow)
at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ObjectExplorer.ShowError(Exception e)
at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.Service.Start()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)

In addition if you check the SQL Server Logs, the current log for SQL Server Agent will be blank or will have nothing logged recently (this is important)

More Info

If you are seeing up to date events in the SQL Server Agent log, then this fix likely does not apply to your situation. If you have a blank or a stationary log file then chances are it does.

Basically, the SQL Server Agent is refusing to start because it cannot write TO the log file. Obviously it is extremely hard to have the process termination log or output that fact otherwise Microsoft would have done it already… sigh.

The Fix

It is probably either or both of:

  1. Check the error log file path for accuracy
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.MSSQLSERVER\SQLServerAgent
    Reg_SZ: ErrorLogFile
  2. Check the file / folder permissions for the path stated above, the SQLAGENT.OUT file and the SQLAGENT.# files. You can either reset them so that the SQL Server Agent’s process account has Full Control access or (depending on your logging policy) delete the files and SQL Server Agent will re-create the logs at startup

PEAR for PHP Error “No releases available for package “xxx” install failed” after running ‘pear install xxx’ on Windows Server 2008

System Requirements:

  • Windows Vista
  • Windows 7
  • Windows Server 2008, 2008 R2

The Problem:

You know that something a bit odd is going on when one of a batch of servers starts throwing errors that the others sailed past. In this case trying to configure PEAR for a new PHP install with Mail, Mail_Mime and Net_SMTP (pear.php.net/mail, pear.php.net/mail_mime and pear.php.net/net_smtp) should be fairly standard. The other servers took the install and even this server too Mail and Mail_Mime but would not accept Net_SMTP returning:

C:\Program Files (x86)\PHP>pear install net_smtp
No releases available for package “pear.php.net/net_smtp”
install failed

Leaving it overnight before rolling up my sleeves (in case it was just downtime at the package repository) the fix was fairly simple.

The Fix

If you are experiencing the same problem this server was having, running the following

pear remote-list

Will result in

SECURITY ERROR: Will not write to C:\Users\<user[8.3]>\AppData\Local\Temp\pear\cache\e9b88593398eb79a9aa91024351d646arest.cacheid as it is symlinked to C:\Users\<user>\AppData\Local\Temp\pear\cache\e9b88593398eb79a9aa91024351d646arest.cacheid – Possible symlink attack

If you get something akin to the above simply browse to:

C:\Users\<user>\AppData\Local\Temp\

and delete the pear folder

“Service reached limit of transient errors. Will shut down. Last error returned from Service Manager: 0x80029c4a” when trying to install .net Framework 3.0 on Server 2008 or .net Framework updates from Windows Update

System Requirements:

  • Windows Vista
  • Windows 7
  • Windows Server 2008, 2008 R2

The Problem:

So we had a server with a corrupted .net installation, Windows Update kept on trying to install a .net 3.5 QFE and failed it, which showed up on the SUS server error logs. Investigation revealed that it would not install the update.

After running the .net cleaner utility, Windows Update still insisted that the machine needed the QFE – despite the fact that .net 4, 3.5, 3.0, 2.0 and 1.x were not installed.

The next obvious step was to put .net back on the machine, starting with 3.0 in the Windows Server Manager ‘Features’ list. It would not reinstall the feature however terminating with

Service reached limit of transient errors. Will shut down. Last error returned from Service Manager: 0x80029c4a

There were two problems here

  1. A .net Framework update was stuck in the Windows Update Catalogue and could not be cleared (even by purging SoftwareDistribution)
  2. The .net Framework 3.0 feature could not be reinstalled onto the operating system via Windows Server Manager

The Fix

In this instance the following solved the problem:

  1. Browse to:
    C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
  2. Check to see if there is a machine.config file present within the folder
  3. If there is not, make a copy of machine.config.default in the same folder and rename it to machine.config

Note that you may need to look through other folders under C:\Windows\Microsoft.NET\Framework for this .config file as the ‘v2.0.50727’ part changes with the service release.

 

Once this was done, .net 3.0 could be reinstalled from Windows Server Manager. Once that was done .net 3.5 SP1 could be reinstalled (along with .net 2.0 SP2 and .net 3.0 updates). This allowed the stuck update to actually install and cleared the original error from WSUS.

After that .net 4.0 went back on and everything on the server was back to normal again.

…the toe bone connected to the foot bone, and the foot bone connected to the ankle bone, and the ankle…

Error 0x80070005 when using SWbemLocator.ConnectServer to initiate a WMI session despite using the correct username and password

System Requirements:

  • WMI 1.5 or higher
  • Windows 95, 98, 98SE, Millennium
  • Windows NT 4.0, 2000, XP, 2003, Vista, 2008, 7

The Problem:

When using WMI’s SWbemLocator.ConnectServer class to log onto a remote system, you receive an 0x80070005 access denied error (Decimal -2147024891).

This error occurs even though the username and password are correct and the account credentials are synchronised properly between the local and remote machine – either by domain or manually in a workgroup.

More Info

The classfull connection line for using SWbemLocator is:

Set objWMIService = objSWbemLocator.ConnectServer(<computerName>, <wmiDefaultClassPath>, <username>, <password>)

for example:

Set objWMIService = objSWbemLocator.ConnectServer("192.168.0.100", "root\cimv2", "Administrator", "12345abcde")

The Fix

There is a very good chance that the problem you are having is to do with the username you are entering. You need to ensure that you are prefixing the username with the logon domain.

For example if your domain is camie.local your username should be camie\Administrator

Set objWMIService = objSWbemLocator.ConnectServer("192.168.0.100", "root\cimv2", "camie\Administrator", "12345abcde")

But I’m using a workgroup!

Don’t worry, you can do one of three things.

  1. Prefix the remote machine name (the local logon domain)
  2. Prefix the workgroup
  3. Send a null logon domain
Set objWMIService = objSWbemLocator.ConnectServer("192.168.0.100", "root\cimv2", "myHostName\Administrator", "12345abcde")

Set objWMIService = objSWbemLocator.ConnectServer("192.168.0.100", "root\cimv2", "workgroup\Administrator", "12345abcde")

Set objWMIService = objSWbemLocator.ConnectServer("192.168.0.100", "root\cimv2", "\Administrator", "12345abcde")

Using one of the above, you should be able to connect to the remote workstation. If you are dealing with a mix of workgroups or cannot know the hostname in advance I suggest using \<username> with I have tested to work on Windows 95 right through to Windows 7.