Windows Management Instrumentation could not initialize

My problem was that I could not start the ”Windows Management Instrumentation” service in Windows XP. The application I am working on uses WMI so I needed this to work. The error message in the eventlog said that it could not initialize.

This is what worked for me as a solution:
1. I deleted all files in %SystemRoot%\System32\Wbem\Repository
2. Started cmd.exe and ran the following commands
winmgmt /clearadap
winmgmt /kill
winmgmt /unregserver
winmgmt /regserver
winmgmt /resyncperf
3. Started the WMI service and it worked for me…

Running Windows 7 on an Asus Z9100 laptop

I have got this old Asus Z9100 laptop and tried to install Windows 7 on it. Windows 7 is not supported on this machine and there are no drivers available. Asus stopped supporting this machine with Windows XP. The machine isn’t that bad so if I got it running it could be a great spare/lab computer.

Specifications
Processor: Intel Celeron M 370 1.5GHz
RAM: 512MB DDR (2x256MB,PC2700)
Graphics: Intel(R) 82852/82855 GM/GME Graphics
Hard drive: 40GB

The installation of Windows 7 was straight forward and I was up and running in no-time. In ”device manager” I only had a few missing drivers and when I made a ”windows update” only ”PCI modem” and the graphics driver was still missing. I can live without the modem but I really wanted the graphics to be ok, it is no fun to be running in the standard vga mode (Standard VGA Graphics Adaptor).

I tried to use the Asus XP driver in compability mode but with no success. It installed fine but was lost after each reboot. I tried with everything that I could think of but the driver was always rejected after booting.

After a while I found the solution in this thread.

The driver to use for the 82852/82855 GM graphics card in Windows 7 is this one: 855gm_vista_driver

Download the file and follow these instructions:

A. Turn off Digital Driver Signing Check

1. Create a shortcut on the desktop to cmd.exe (In the location box type cmd /k)
2. Right-click on the shortcut and select Run as administrator
3.When the command window opens, type the following and press ENTER after each:
bcdedit /set nointegritychecks ON
bcdedit /set loadoptions DDISABLE_INTEGRITY_CHECKS
4. Reboot in safe mode (press F8 repeatedly during the BIOS screen).

B. Installing the XDDM Vista Driver

1. With computer in safe mode, open the Device Manager
(Start > Computer > System Properties > Device Manager)
2. Initiate driver update for Standard VGA Graphics Adaptor
(Properties > Driver Tab > Update Driver > Update driver -> Browse -> Let me pick -> Display adapters -> Have disk -> give path to ”855gm_vista_driver ” folder of the extracted driver)
3. Navigate to the folder where the driver is stored then complete the installation.
4. In the Device Manager, initiate a new hardware scan (Action > Scan for Hardware Changes).
5. Reboot. If successful, create a restore point!

After following these instructions everything started to work. Max resolution is now at 1024×768. I can choose Aero-themes but they are not working because the drivers are not made for Windows 7.

The Windows 7 performance for the Asus Z9100 is not that good but it is definitely satisfying for simple home use.

Summary: Very nice, I now have a ”new” computer running pretty good.

How to install a shared network printer with VB.NET and WMI

Today I show you an example of how to install a network printer with VB.NET and WMI by using the AddPrinterConnection method of the wmi Win32_Printer class. Just replace hostname with the name of the printserver/workstation and queuename with the shared printer queuename.

        Try

            Dim scope As ManagementScope = New ManagementScope("root\CIMV2")
            scope.Options.Impersonation = ImpersonationLevel.Impersonate
            scope.Connect()

            Dim path As New ManagementPath("Win32_Printer")
            Dim mgtClass As New ManagementClass(scope, path, Nothing)

            Dim inputParameters As ManagementBaseObject = mgtClass.GetMethodParameters("AddPrinterConnection")
            inputParameters("Name") = "\\hostname\queuename"

            Dim outputParameters As ManagementBaseObject = mgtClass.InvokeMethod("AddPrinterConnection", inputParameters, Nothing)
            Dim returnValue As UInteger = UInteger.Parse(outputParameters("ReturnValue"))

            If (returnValue = 0) Then
                Console.WriteLine("Success")
            ElseIf (returnValue = 5) Then
                Console.WriteLine("Access Denied")
            ElseIf (returnValue = 1801) Then
                Console.WriteLine("Invalid Printer Name")
            ElseIf (returnValue = 1930) Then
                Console.WriteLine("Incompatible Printer Driver")
            End If

        Catch ex As Exception

        End Try

Mina försök att använda HTPC’n som trådlös router i Windows 7

Jag har under sommaren laborerat med min HTPC så att den ska kunna dela ut mobilt bredband i sommarstugan med Windows 7 utan att behöva koppla in någon router. Man kan ju förvandla sin Windows 7 dator till att fungera som en trådlös router genom att använda ConnectifyMe, Virtual Router eller att använda sig av kommandoraden.

Jag har nu efter 1 månads testning gett upp försöket efter att ha testat alla dessa lösningar. Det som jag fick att fungera bäst var kommandorads-versionen men även den fungerade dåligt i längden. Det första jag märkte var att det sög rätt mycket kräm ur HTPC’n som skulle fungera som WIFI-hotspot (även om inga klienter var inkopplade). Det andra var att internet-uppkopplingen till de trådlösa klienterna försvann med jämna mellanrum. Jag testade med två olika 3G-modem i HTPC’n och uppkopplingen dog ändå. Vet inte vad det berodde på och orkar inte undersöka det mer, men antagligen är det något internt i Windows som spökar. Det lustiga var att uppkopplingen i vissa fall fungerade i själva HTPC’n men inte i trådlösa nätet. Det tredje ”dåliga” var att man inte har sån stor koll på vad som händer i nätet och man har inga möjligheter att ställa in de parametrar som vanligtvis finns i en router. Och till sist så tyckte jag att throughput’en (hastigheten) på trådlösa nätet försämrades drastiskt.

Nu har jag alltså gett upp och delar ut mobilt bredband trådlöst med en vanlig hårdvaru-router inkopplad till HTPC’n istället. Hur man gör detta kan man läsa här. Detta fungerar nu mycket bättre. Om M$ hade lagt lite mer tanke bakom den här funktionaliteten så hade det varit en riktig ”killer-feature”, men nu känns det lite väl omoget.

My Windows 7 experiences and setup

One year has passed since my first tryout of Windows 7. The transition from Windows XP was easy and I won’t go back. Well thats not entirely correct, because my arcade machine (coming up blogpost) run a very fast and good version of XP called Tiny XP.

I have had the same ”install” the entire year and tried a lot of things with it. The usual problem with having the same install too long has now began to show itself. More problem than I can handle! The only solution is as usual to reinstall everything. This time I am going with a dual-boot setup with Win7 and Ubuntu.

The most annoying thing with ”Windows 7” has so far been the new ”Windows explorer” (explorer.exe) which I think is bloated. There is no way that I can be productive as earlier with that crap. And I can’t even make it work in ”classical mode”. I have stopped using it! The most perfect file browser in my mind is the classical windows explorer which Microsoft stopped using with Windows XP. I have tried a lot of file browsers and xplorer² is a good replacement. That program is actually the first program I install on a new computer.

Some of my setup tweaks

Lets share some of the tweaks I use to make my Win7 feel good. It is also good for me to have a checklist when I install Win7 the next time.

1) Live Messenger

Minimize Windows Live Messenger to systray

Make Live Messenger cleaner by patching it

2) Taskbar and systray

Bring back good old ”Quick launch”

Unpin all programs from taskbar

Taskbar properties: Check ”Use small icons” and ”combine when taskbar is full”

3) Personalize

In the beginning I switched of all aero stuff and used ”Windows Classic” theme. But by now I am actually used to all fancy aero stuff and it doesn’t feel that my machines performance is that much affected by this.

4) Services and startup

I try to disable as many services that is possible or set them to start manual. Services eat memory and CPU-time.

I continually check msconfig.exe (or registry) to sanitize startup programs. More startup-programs makes your computer boot slower.

5) Programs

I try to keep my program list clean. If I do not use a program I remove it. You never know what services and resources a program uses.

If I want to check stuff out I do that in a virtual machine instead of my ”production machine”. It is very handy to have some lab virtual machines if you are a software developer.

6) Useful free programs

Image Resizer Powertoy Clone for Windows
xplorer² (file manager)
Putty (ssh)
WinSCP (moving files with ftp/sftp)
CDBurnerXP
K-lite codec pack (media playing codecs)
Avast antivirus
Filezilla (ftp)
uTorrent
CutePDF Writer
DAEMON Tools Lite
OpenOffice
Firefox
7-zip (file archiver for zip, rar…)
Notepad++ (text editor)

Troubleshoooting device driver installation with setupapilog.txt

Today I tried to install the ”HP Universal Driver PCL6” (32-bit) on a Windows XP machine with WMI and VB.NET. All I got was the errorcode 2 and a failed installation. What does that mean? Windows errorcodes is not my (anyones?) speciality…

After some googling I found this very good post that describes the problem and a possible solution.

The key to solving this puzzle and possibly other device installation problems is the file setupapi.log in the windows folder. After running my code again I got this in my setupapi.log file (in swedish):

[SetupAPI Log]
OS-version = 5.1.2600 Service Pack 3
Plattforms-ID = 2 (NT)
Service Pack = 3.0
Svit = 0x0100
Produkttyp = 1
Arkitektur = 2006157608
[2010/01/22 14:20:41 5392.4 Driver Install]
#-198 Bearbetad kommandorad: C:\WINNT\system32\wbem\wmiprvse.exe
#I060 Ange vald drivrutin.
#I060 Ange vald drivrutin.
[2010/01/22 14:20:41 5392.5]
#-198 Bearbetad kommandorad: C:\WINNT\system32\wbem\wmiprvse.exe
#-167 SPFILENOTIFY_NEEDMEDIA: Tagg = p6i2svww.cab, Beskrivning= PDL_LANG, Källsökväg = C:\CentralPrintArea\FKPrint\HP\Universal\32bit\HP Universal, Källfil = UNIDRV.HLP, Flaggor = 0x00000000.
#E169 SPFILENOTIFY_NEEDMEDIA: returnerade FILEOP_ABORT. Fel 2: Det går inte att hitta filen.
#W187 Installationen misslyckades. Försök att återställa originalfiler utförs.

It says that I got an errorcode 2 (missing file) and which file that is missing. In this case it is missing the file ”UNIDRV.HLP” that is not available in swedish. All I had to do is to extract this file from the cab-file ”p6i2svww.cab” to the root of the driverfolder. After doing this and running the program once more everything is working and the driver installs. After this I get the following output in setupapi.log.

[SetupAPI Log]
OS-version = 5.1.2600 Service Pack 3
Plattforms-ID = 2 (NT)
Service Pack = 3.0
Svit = 0x0100
Produkttyp = 1
Arkitektur = 2006157608
[2010/01/22 14:28:43 4784.4 Driver Install]
#-198 Bearbetad kommandorad: C:\WINNT\system32\wbem\wmiprvse.exe
#I060 Ange vald drivrutin.
#I060 Ange vald drivrutin.

That looks good I suppose! At least better then before. And the driver is installed ok!

You can read and download information about setupapilog.txt at the Microsoft website. If you read the whitepaper you could possibly solve many kinds of STRANGE device driver installation problems.

This is Microsofts description of setupapilog.txt

Windows XP and later versions log system operations more extensively than previous versions of Windows do. One of the most useful log files for debugging is the SetupAPI log file (setupapi.log). This plain-text file maintains the information that SetupAPI records about device installation, service-pack installation, and hotfix installation. Specifically, the file maintains a record of device and driver changes, as well as major system changes,

If you wnat more verbose logging to the setupapi.txt file you can edit the windows registry key ”HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\LogLevel”. If you raise this value to 255 you get a lot of logging which can be useful at times.

I hope this helps someone and that HP fixes the broken driver. It must be some sort of localization problem within this driver. Or maybe that I have the wrong driver…

The path to this file in Windows XP is %WINDIR%\Setupapi.log. On Windows Server 2008R2 the log files are found in %WINDIR%\Inf\ and are called setupapi.app and setupapi.dev.

There is always something new to learn in the Windows world! Happy troubleshooting!

How to create a printerqueu with .NET and WMI

This is an example of how you create a printerqueue with .NET and WMI (Windows Management Instrumentation).

A list of properties can be found at MSDN Win32_Printer

Other topics:
How to install printerdrivers with wmi and VB.NET
How to create TCP/IP printerports with .NET

Imports System.Management

Dim shared as Boolean = true

Try
 Dim mp As ManagementPath = New ManagementPath("Win32_Printer")
 Dim co As ConnectionOptions = New ConnectionOptions()
 co.EnablePrivileges = True
 co.Impersonation = ImpersonationLevel.Impersonate
 
 Dim ms As ManagementScope = New ManagementScope("\\" + Environment.MachineName + "\root\cimv2", co)

 Dim printerObject As ManagementObject = New ManagementClass(ms, mp, Nothing).CreateInstance()
 printerObject("PortName") = "IP_192.168.0.2"
 printerObject("DriverName") = "DriverName"
 printerObject("DeviceID") = "queuename"
 printerObject("Location") = "Placement of printer"
 printerObject("Comment") = "Some comments"

 If (shared) Then
  printerObject("Shared") = True
  printerObject("ShareName") = "Sharename"
  'printerObject("Published") = False ' Publish printer
 End If

 Dim options As PutOptions = New PutOptions()
 options.Type = PutType.UpdateOrCreate
 printerObject.Put(options)

Catch ex As Exception
 ' Do something
End Try

Install printerports with WMI and VB.NET

This is an example of how you install TCP/IP printerports with .NET and WMI (Windows Management Instrumentation).

A list of properties can be found at MSDN Win32_TCPIPPrinterPort

Other topics:
How to install printerdrivers with wmi and VB.NET
How to create a printerqueu with .NET and WMI

Imports System.Management

Try
  Dim mp As ManagementPath = New ManagementPath("Win32_TCPIPPrinterPort")
  Dim co As ConnectionOptions = New ConnectionOptions()
  co.EnablePrivileges = True

  Dim ms As ManagementScope = New ManagementScope("\\" + Environment.MachineName + "\root\cimv2", co)

  Dim port As ManagementObject = New ManagementClass(ms, mp, Nothing).CreateInstance()
  port.SetPropertyValue("Name", "portname")
  port.SetPropertyValue("Protocol", 1)
  port.SetPropertyValue("HostAddress", "10.15.12.12")
  port.SetPropertyValue("PortNumber", "9100")

  Dim po As PutOptions = New PutOptions()
  po.UseAmendedQualifiers = True
  po.Type = PutType.UpdateOrCreate
  port.Put(po)
Catch ex As Exception
  ' do something
End Try

Marvel 6162 SATA driver for Windows 7

There isn’t any driver for the Marvel 6162 (88SE6162) SATA controller in Windows 7 (32-bit). For my motherboard (Asus M2V) I needed this driver and I could not find them on the Asus support website. I guess Asus havn’t made these available yet. Lazy bastards! After some modifications to the Vista-drivers I could use them instead.

marvel-6162-sata-driver

If you download and try to install the Vista-drivers you get a message like ”Does not support this Operating System : WNT_6.1P_MCE”. To be able to run the installer you need to edit the AsusSetup.ini file with notepad. The only thing you need to do is add a line corresponding to your Operatingsystem (WNT_6.1P_MCE) in the [OS_Language_Tag] section of the file.

I have prepared a file for Windows 7 32-bit that you can use:
Download Marvell_SATA_V10215B2 driver.

You only have to extract the files and run the AsusSetup file in the driver/x32 folder. If you run Windows 7 64-bit you can use the same files and make the same changes. If someone does this then please contribute to this post.

The driver installs and works great. My SATA-drive that is connected to the SATA-controller has appeared and I am happy again.

Problem installing Windows 7 on Asus motherboards

For the last 5 hours I tried to install Windows 7 (x86, 32bit) on my home computer that has an Asus M2V motherboard. I tried everything in the book and couldn’t install it. I removed and switched hardware, reburned the DVD, updated the BIOS and did everything that I could possibly think of. The installation process always hung when the installer says ”expanding windows files”. No error messages or nothing and the installation percentage counter stops at a random number. That really pissed me of!

Finally I found an answer to this really weird behaviour. It seems that this is common problem on Asus motherboards and Windows 7.

In BIOS you have to make these changes to make it work:
* Enable the floppy drive (I had it disabled because I dont have a floppy drive).
* Disable the ”Cool and quite” feature.

After I made these changes the installation worked!

I hope this helps other people stuck with the really annoying ”Windows 7” installer.