Saturday, October 30, 2010

Monday, October 4, 2010

Insert a disc with more space

Anyone know where I can get a disc with 819 petabyte so I can retry?

space_needed

Wednesday, September 15, 2010

Windows Phone 7 Features and Rumors roundup

My last blog entry about smart phones has produces quite some response, but interestingly all via email. Okay, nobody likes the comment function. Got it.

Meanwhile, new features/rumors/lies (pick one) have emerged, so I’m trying to sum them all up here.

  • Updates for Windows Phone 7 will be released directly by Microsoft

    This is very good since this means you (should) always have the newest release available on your phone. This is better than in Android where the handset maker needs to push out the update (currently only 25% of all Android devices have the newest version 2.2). Given that smart phones are more and more targeted with malware, this should also increase security.
     
  • No carrier lock

    WP7 does not come with any carrier lock-in, so this means you can simply buy a WP7 phone without a contract and use it with any carrier. There might be phones that will be available only at some carrier, but given that Microsoft has defined very strict hardware requirements, it shouldn’t be a problem to find something similar with ease.
     
  • “My Phone” feature

    Microsoft has already a site and application called “My Phone” that can be used to backup the data on your phone automatically or ring the phone if you have lost it it somewhere. WP7 will also allow to remote wipe the phone or lock it and display a message. If you every lost a phone, you will love this feature.
     
  • Any app must disclose advanced services it intends to use

    Any app that intents to use advanced features of the phone (e.g. the GPS receiver) must disclose this to WP7 which in turn will display this list to the user upon the installation of the app. So, if an app want to use push notification you are asked during the installation if this is okay with you.

    If an app tries to use a feature that hasn’t been disclosed, it will be shut down. Although this is borrowed from Android, this really puts the user in control. Any BTW: The iPhone does not have anything close to this.

  • Zune Pass available

    As it seems, WP7 users worldwide will have access to Zune Pass for round about 12€/month. This give you the ability to listen to any song they have in their library as long as you subscription is active. Per month, you can also keep 10 songs at no additional cost.
     
  • Very clever UI ideas

    WP7 as without any doubt some very clear user interface ideas. My favorite is the idea that the camera shows the live picture and a “slider” on the left. Simply swipe left to right and you see the lat phone taken. Swipe right to left and you’re back on the live preview. Usability: A+.
     
  • Microsoft will only allow five free apps per developer

    Yes, this is a restriction but actually a good one. We all know that there are several developers out there that make 10 apps “Slideshow Person X”, “Slideshow Person Y”, “Slideshow Person Z” etc. This restriction might not solve this problem, but should improve the situation of having the 457th flashlight app.
     
  • Payment will not be using Microsoft Points

    Payment is still a big topic. Apple does currently the best job (matching *.99€/$ prices, payable directly with a credit card etc.) and Android/Google Checkout is the worst example. Microsoft will not use their own “currency” Points, but allow direct Credit Card payments with adapted pricing per Country (0.99€ in Europe and 0.99$ in the States)

Please note that nothing major has changed from what I said in my last post. Windows Phone 7 has a nice user interface with a great runtime (.NET/Silverlight) and a near-perfect development tool (Visual Studio). But it also comes with some very big FAILS like the enforced App Store with a censorship review process.

Windows Phone 7 is definitely worth a look once it’s available.

Tuesday, September 14, 2010

Xbox in Leetspeak

Now this explains why Microsoft has offered a Xbox 31it3 in the past…

 IMG_1224

Monday, September 6, 2010

Samsung Galaxy S (Android 2.1) USSD codes not working

Today, I wanted to use some of my carrier USSD codes (e.g. *120#) on my Galaxy S and they didn’t worked.

I entered them, but the Galaxy refused to display anything. After some searching I found out that this comes from the Mobile Tracker I had activated.

As soon as you active Mobile Tracker (Settings –> Location and security –> Mobile tracker) no USSD codes will work.

Disabled Mobile Tracker and the codes were working again. Go figure…

Wednesday, September 1, 2010

Random item name generator in DeathSpank style

I have to admit, I couldn’t resist.

The RandomPersonNameGenerator was a very good starting point to create the RandomItemNameGenerator, which creates role play game item names in DeathSpank style.

Here are some of the results this class generates:

  • Failing Manual of Failing
  • Fluffy Rocket of Impending Doom
  • Epic Dynamite Kit
  • Functional Bacon of Function
  • Sparkling Fly Swatter of Impending Doom
  • OMG Dynamite of Awesomeness
  • Glowing Chicken of Function
  • Fluffy Rocket of Function
  • Heroic Crowbar Kit
  • OMG Orb Kit
  • Fluffy Manual of Awesomeness
  • Normal Crowbar of Function
  • Epic Bacon Kit
  • Functional Fly Swatter of Function
  • Sparkling Anvil of Failing
  • Fluffy Orb of CAPSLOCK

Yes, this does not make any sense. And no, there is for sure no project where you can use it. And yes, it was a total waste of time. But for the fun, it was worth it :-).

using System;
using System.Collections.Generic;

#region License

//For an explanation see http://www.opensource.org/licenses/bsd-license.php

/*
Copyright (c) 2010, TeX HeX / Xteq Systems
http://www.texhex.info/ http://www.xteq.com/
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice, this
    list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.
  * Neither the name of the Xteq Systems nor the names of its contributors may
    be used to endorse or promote products derived from this software without
    specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#endregion

namespace RandomGenerator
{
    public class RandomItemName
    {
        public string Prefix { get; set; }   //  Epic
        public string Name { get; set; }     //  Chest
        public string Suffix { get; set; }   //  of Awesomeness
        public string Full { get; set; }     //  Epic Chest of Awesomeness

        public override string ToString()
        {
            return Full;
        }
    }

    public class RandomItemNameGenerator
    {
        #region Name arrays

        static readonly string[] _prefixNameSet = new string[] {
            "Epic", "Heroic", "Normal", "Glowing", "Functional",
            "Sparkling", "Fluffy", "OMG", "Failing"
        };
        static readonly int _prefixNameSetCount = _prefixNameSet.GetUpperBound(0) + 1;

        static readonly string[] _itemNameSet = new string[] {
            "Chest", "Dynamite", "Chicken", "Orb", "Bacon", "Manual" ,
            "Crowbar", "Anvil", "Fly Swatter", "Rocket", "Scarab"
        };
        static readonly int _itemNameSetCount = _itemNameSet.GetUpperBound(0) + 1;

        static readonly string[] _suffixNameSet = new string[] {
            "of Impending Doom" , "of Function", "of Awesomeness", "Kit",
            "of CAPSLOCK", "of Failing"
        };
        #endregion
        static readonly int _suffixNameSetCount = _suffixNameSet.GetUpperBound(0) + 1;

        RandomItemName GenerateOne(Random rndm)
        {
            int iRandomValuePrefix = rndm.Next(0, _prefixNameSetCount);
            int iRandomValueName = rndm.Next(0, _itemNameSetCount);
            int iRandomValueSuffix = rndm.Next(0, _suffixNameSetCount);

            RandomItemName rpi = new RandomItemName();

            rpi.Prefix=_prefixNameSet[iRandomValuePrefix];
            rpi.Name=_itemNameSet[iRandomValueName];
            rpi.Suffix=_suffixNameSet[iRandomValueSuffix];

            rpi.Full = rpi.Prefix + " " + rpi.Name + " " + rpi.Suffix;

            return rpi;
        }

        public List<RandomItemName> Generate(int Count)
        {
            List<RandomItemName> list = new List<RandomItemName>();

            Random rndm = new Random();

            for (int i = 0; i < Count; i++)
            {
                list.Add(GenerateOne(rndm));
            }

            return list;
        }

        public static List<RandomItemName> StaticGenerate(int Count)
        {
            RandomItemNameGenerator ring_ring = new RandomItemNameGenerator();
            return ring_ring.Generate(Count);
        }

    }
}

Tuesday, August 31, 2010

A generator for random person names

During the creation of a project, I often need to generate test data to test the applications. Quite frequently this happens when there is (yet) no database backend available so I need to generate the test data directly inside the program.

Usually, this also involves test data of persons (or users, customers, suppliers etc.). Over time I really got sick of my imaginative creations like “AAA 1”, “ZRIQW 44” and of course the well known “sdsfghsdfj, sdf934md930”.

Thats why I have generated the RandomPersonNameGenerator class that uses the top 30 names from the 1990 census of the U.S. Census Bureau to generate random person names.

The usage is very simple:

RandomPersonNameGenerator rpGen = new RandomPersonNameGenerator();
List<RandomPersonName> list = rpGen.Generate(100);

foreach (RandomPersonName rpn in list)
{
    Console.WriteLine(rpn);
}

The result will look like this:

image

You can also use the static method and directly access one of the properties of the resulting RandomPersonName objects.

List<RandomPersonName> list = RandomPersonNameGenerator.StaticGenerate(100);

foreach (RandomPersonName rpn in list)
{
    Console.WriteLine(rpn.LastCommaFirst);
}

image

 

The class is released under the new BSD license. Enjoy!

 

using System;
using System.Collections.Generic;

#region License

//For an explanation see http://www.opensource.org/licenses/bsd-license.php

/*
Copyright (c) 2010, TeX HeX / Xteq Systems
http://www.texhex.info/ http://www.xteq.com/
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice, this
    list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.
  * Neither the name of the Xteq Systems nor the names of its contributors may
    be used to endorse or promote products derived from this software without
    specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#endregion

namespace RandomGenerator
{
    /// <summary>
    /// This class is used to store a name and give easy access to the differnt parts of it.
    /// </summary>
    public class RandomPersonName
    {
        public string First { get; set; } //          Michael
        public string Last { get; set; } //           Hex
        public string Full { get; set; } //           Michael Hex
        public string LastCommaFirst { get; set; }//  Hex, Michael

        public override string ToString()
        {
            return Full;
        }
    }

    /// <summary>
    /// Can be used to easily generate person name like "Michael Taylor", "Lisa Smith" etc.
    /// All names are returned as a RandomPersonName object.
    /// </summary>
    public class RandomPersonNameGenerator
    {
        #region Name arrays
        //All these names (with slight modifications) retrieved from here:
        //
        //
http://www.census.gov/genealogy/www/data/1990surnames/
        //
        static readonly string[] _firstNameMaleSet =new string[] {
         "James", "John", "Robert", "Michael", "William", "David", "Richard", "Charles", "Joseph",
         "Thomas", "Christopher", "Daniel", "Paul", "Mark", "Donald", "George", "Kenneth",
         "Steven",  "Dirk", "Brian", "Ronald", "Anthony", "Kevin", "Jason", "Matthew", "Gary",
         "Timothy", "Jose", "Larry", "Jeffrey"
        };
        static readonly int _firstNameMaleSetCount = _firstNameMaleSet.GetUpperBound(0)+1;

        static readonly string[] _firstNameFemaleSet = new string[] {
            "Mary", "Patricia", "Linda", "Barbara", "Elizabeth", "Jennifer", "Maria", "Susan",
            "Margaret", "Melanie", "Lisa", "Nancy", "Karen", "Betty", "Helen", "Sandra", "Donna",
            "Carol", "Ruth", "Sharon", "Michelle", "Laura", "Sarah", "Kimberly", "Deborah", "Jessica",
            "Shirley", "Cynthia", "Angela", "Melissa"
        };
        static readonly int _firstNameFemaleSetCount = _firstNameFemaleSet.GetUpperBound(0)+1;

        static readonly string[] _lastNameSet = new string[] {
            "Smith", "Johnson", "Williams", "Jones", "Brown", "Davis", "Miller", "Wilson", "Moore",
            "Taylor", "Anderson", "Parker", "Jackson", "Norris", "Harris", "Hex", "Thompson",
            "Garcia", "Martinez", "Robinson", "Clark", "Rodriguez", "Lewis", "Lee", "Walker", "Hall",
            "Allen", "Young", "Hernandez", "King"
        };
        #endregion
        static readonly int _lastNameSetCount = _lastNameSet.GetUpperBound(0)+1;

        RandomPersonName GenerateOne(Random rndm)
        {
            int iRandomValueMale = rndm.Next(0, _firstNameMaleSetCount);
            int iRandomValueFemale = rndm.Next(0, _firstNameFemaleSetCount);
            int iRandomValueLastName = rndm.Next(0, _lastNameSetCount);
            RandomPersonName rpn = new RandomPersonName();

            rpn.First = rndm.Next(0, 2) == 0 ? _firstNameMaleSet[iRandomValueMale] : _firstNameFemaleSet[iRandomValueFemale];
            rpn.Last = _lastNameSet[iRandomValueLastName];
            rpn.Full = rpn.First + " " + rpn.Last;
            rpn.LastCommaFirst = rpn.Last + ", " + rpn.First;
            return rpn;
        }

        /// <summary>
        /// Returns a list of RandomPersonName objects.
        /// </summary>
        /// <param name="Count">Count of names that should be generated</param>
        /// <returns>List of RandomPersonName objects</returns>
        public List<RandomPersonName> Generate(int Count)
        {
            List<RandomPersonName> list = new List<RandomPersonName>();           

            Random rndm = new Random();

            for (int i = 0; i < Count; i++ )
            {
                list.Add(GenerateOne(rndm));
            }

            return list;
        }

        /// <summary>
        /// Returns a list of RandomPersonName objects (Static function)
        /// </summary>
        /// <param name="Count">Count of names that should be generated</param>
        /// <returns>List of RandomPersonName objects</returns>
        public static List<RandomPersonName> StaticGenerate(int Count)
        {
            RandomPersonNameGenerator rpng = new RandomPersonNameGenerator();
            return rpng.Generate(Count);
        }

    }
}

Thursday, August 26, 2010

Something is wrong with the version number

Maybe we could agree that it wasn’t a version number at all?

version

Friday, August 20, 2010

Error starting Error Reporting

Keep on trying Windows, one day you will succeed…

Error while using error reporting

Wednesday, August 11, 2010

Update or install Flash Player without DLM

As Adobe has released a new version of Flash Player today, I thought I should share how you can update or install Flash Player without using Adobe Download Manager (DLM).

Simply use the link for the browser you want to update below. You can also bookmark them as they will always return the current version.

[Update: Links have changed with Flash Player 11 – Thanks to Explorer]

For Internet Explorer:

32 bit (x86):
http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player_ax_32bit.exe

64 bit (x64):
http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player_ax_64bit.exe

For any other browser (Firefox etc.)

32 bit (x86):
http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player_32bit.exe

64 bit (x64):
http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player_64bit.exe


To test if the installation was successful and if you have the updated version, go to this page:
http://www.adobe.com/software/flash/about/

Wednesday, August 4, 2010

My rambling thoughts about smartphones

To be honest, this post was on my disk for nearly two months now. I have changed it often, but still I think it’s not complete. Anyhow, I doubt that will get any better so I’m publishing it.

 

As my current phone, a Samsung i780, is rather old I started to search for a replacement. I looked at the currently available phones both from a customer perspective as well as from developer view -mobile app development is still a very hot topic.

After all, it came down to the “big three”: Apple iPhone, Google Android and BlackBerry. As an extra, I also checked Windows Phone 7.

I didn’t know BlackBerry quite well but fortunately I have one here as a current client insisted that I use it while working on the project. This was the easiest decision of all: Looking at all the features it’s clear to me that BlackBerry is developed for big enterprises, not the normal customer. For app development, each paid application you submit will cost you 200$ (with 10 updates free). Once you have submitted 10 updates, you need to pay 200$ again. No, not the phone I was looking for.

 

For the Apple iPhone I think you can name it “Best phone with best vendor lock-in”. Without any doubt, the iPhone 4 has the best display money can buy, fits exactly in your hand, runs quite a long time on batteries and iOS is definitely mature. On top, you get the best filled app store around. So this should be a no-brainer, right? No.

Because if you move a little ahead, you end up being limited to what Steve Jobs thinks is good for you. This starts when you want to buy it: You can only get with a mobile phone contract from one vendor. Even if you sign this contract, you can’t simply exchange the SIM card as it has a SIM lock. And this is just the start: Replaceable batteries? No. SD card slot? No. Apps outside the app store? No. Developing apps with something else than Apples C/C++/Objective-C? No. Using cross compilers? No. Tethering out of the box? No. And so on.

There is actually good reason for Apple to behave like this: Profit (of course) and control of the platform. Although the iPhone Developer program is rather cheap with 99$, it isn’t what I was looking for. No Steve, I don’t obey. Please keep your iNo iPhone.

 

Moving over to Windows Phone 7: When the read the first report about Microsoft developing a new “iPhone rival” I have to admit I was really think that this will be my new phone. I really thought they will simply take the pieces Apple did right, remove all the stupid parts (all those “NO” entries above) and add some extra features.

After all, Microsoft should has all needed technologies at hand: Multi Touch (Surface), a great runtime with a sandbox (.NET Framework), a very good graphics engine (DirectX), a nice UI (XAML/Silverlight) and by the way: they are producing operating systems as well.

Well, these were my first thoughts but as now more and more details emerge, I’ve learned that Microsoft has completely copied the Apple way including all the great fails.

To start with that you can’t install apps outside the marketplace, that you have no access to an SD card (only for “extending the internal memory”, not for you to simply exchange data) and so on. Although there are some hardware partners, they are not allowed to extend the phone (e.g. HTC Sense or Samsung TouchWiz). If all hardware is basically the same, why should any vendor build a phone then? Remember, a lot of people buy an HTC device because of Sense.

No doubt that Microsoft has currently the most advanced combination of a good runtime (.NET/Silverlight etc.) with a very good development tool (Visual Studio) but with all these Apple fails build in? Nope.

 

Enter Google Android: An open-source smartphone OS released under an Apache license. As the licensing cost for the OS are nearly zero (OS is free, but some Google apps will cost the manufacturer something) it’s now wonder they are dozens of phones available. There is no form factor that isn’t available.

The app store is the second biggest in the world (70k vs. Apple’s 200k) but you are free to install applications outside the store. Heck, you can even create native applications and call them from your “normal” apps. Replaceable batteries, using any carrier, OS “enhancements”, tethering, cross compilers or SD card access? Yes, you can.

So this is happy land, right? Nope. Android isn’t mature so far. Everywhere you will come across little quirks and major bugs.

For example, there is no build-in setting to simple turn off mobile data in the night or after a given period of inactivity (There’s an app for that). The build-in calendar sometimes goes havoc if you change the synchronized accounts (need a “Clear Cache”) and can’t handle time zones. The music player can’t read MP3 tags correctly nor handle genres at all. Choosing a date using the build-in controls does not show you a calendar. A lot of apps are poorly written and will drain your battery in no time. And so on.

But from my point of view, the advantages of Android out weight the failures: I ordered a Samsung Galaxy S (I9000).

 

 

Final note: Why I always want the “Install apps outside the store” feature?

Because any review process is broken by design. For an example, read this.

And if you still believe that “Reviewing” an app is a good way to prevent “bad” apps, see this. When this was not noticed during the censorship review process, what else “under the hood” functions might exist in other apps?

Tuesday, July 27, 2010

Some posts are missing here…

Sorry for the lack of updates in the last time, but the shutdown of X-Setup (and everything that has happened because of it) hit more than I first thought…

Anyway, I should be back on track now so expect normal updates in the future again.

Wednesday, April 7, 2010

Java 1.6 Update 19 failed with Error 266

Just tried to install Java 1.6 Update 19 on a corporate Windows 7 Enterprise Machine and the installation failed with the following message:

Data1.cab has an invalid digital signature (Error 266 returned by WinVerifyTrust)

To cut a long story short: The problem was that the file couldn’t be verified because it was signed with a new certificate by Sun. This new certificate depends on a new VeriSign certificate (Root Authority Certificate) that is by default not included in Windows 7.

Normally Windows updated its list of Root Certificates automatically, but this does not work in this environment since all Internet Connections are blocked.

The solution is rather simple: Download the update file manually from

http://download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/rootsupd.exe

and install this file with the “/Q” switch (no reboot required).

Now Windows has a current set of Root Certificates and the installation of Java will work.

For some more information, see Microsoft KB931125.

Thursday, March 18, 2010

Deleting printers from the command line



There is an updated post on this topic available: Deleting local or network printers as well as printer drivers from the command line


To quickly and silently delete a printer using a command line, use the following command:

rundll32 printui.dll,PrintUIEntry /dl /n "NAME_OF_PRINTER" /q

This command will silently delete the printer and not issue any messages to the user (/q switch).

There is much more you can do with this command, just enter the following to see the list of supported options:

rundll32 printui.dll,PrintUIEntry /?

Saturday, February 13, 2010

Easy SQL Server Backup Tool

Although we are using a “normal” SQL Server, we have also a lot of SQL Server Express running. Mostly these are database were a daily backup is more than enough, for example for Windows Update Services.

So far, we are using customs scripts for each server to backup them, but I wanted a different and more easier way to do it. Once it is set up, all you need to do to backup a new database on the server is to copy a batch file and rename it.

First, create a folder on the server you want to backup, e.g. “C:\SQLServBkp”. Give “NETWORK-SERVICE” write access to this folder. Since SQL Server will do the backup for us, we need to make sure that the account has access to create the backup file.

Secondly, make sure that you have the SQL Server Tools installed since we will use SQLCMD.exe. In case you have only the database installed, you can easily download and install the SQL Server Management Tools. And it’s no problem to use the 2008 version even if your SQL Server Express is only 2005.

Next, create a batch file named C:\SQLServBkp\_SQLBackupWorker.bat with the following contents:

SET SQLCMD_Path=C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE
SET SQLServerInstance=.\sqlexpress

"%SQLCMD_Path%" -S %SQLServerInstance% -E -e -v db=%1 -v bakfile="%~dp0%1_Backup.bak" -i"%~dp0_SQLBackupWorker.sql"

Please note: The last line is ONE single line.

The variable SQLCMD_Path points to SQLCMD.exe, the path that is used here is for the default SQL Server 2008 installation.

The variable SQLServerInstance is the instance of the SQL Server you want to backup; the default is “.\sqlexpress”. In case you want to backup the Windows Internal Database (for example WSUS) you need to write “\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query”. Strange syntax, but it works.

Now we need a file that issues the backup command to the SQL Server, name it C:\SQLServBkp\_SQLBackupWorker.sql

-- SQLBackupWorker.sql START
PRINT 'Running on server ' + @@ServerName
PRINT 'Backing up database [$(db)] to file [$(bakfile)]'
BACKUP DATABASE $(db) TO DISK = '$(bakfile)' WITH INIT
-- SQLBackupWorker.sql END

Finally, simply create one batch file that is named exactly as the database you wish to backup. For example, if you want to backup the database “WhatsUp”, name the file C:\SQLServBkp\WhatsUp.bat and put the following contents in (one line):

call "%~dp0_SQLBackupWorker.bat" %~n0 >"%~dpn0.log"

If you want to backup a second databse, e.g. “NetFlow”, you simply create a file name C:\SQLServBkp\NetFlow.bat and put the exact same contents in as above.

The trick is quite simple: The batch will extract its own name and pass it over to _SQLBackupWorker.bat. This will in turn use it as a name for the backup file and passes it over to _SQLBackupWorker.sql which caries out the backup.

Once this is all set up, give it a try and execute one of the batch files, e.g. WhatsUp.bat. A log file (WhatsUp.log) is automatically created and you can review it. If it seems that nothing is working, check the instance name and make sure that NETWORK-SERVICE has write access to the folder you have created.

You can simply schedule any of the batches with Task Scheduler so they run on a regular basis.

Monday, December 28, 2009

No AC Power = 100% CPU

I just had a funny problem with a HP Notebook, running Windows 7. I usually don’t shut it down but use either Hybrid Sleep (Hibernate + Sleep) or use hibernation directly.

So as ever, I waked the laptop up, waited until it is ready and unplugged it from the AC power. Suddenly one CPU was completely busy. I had no programs open so I was wondering what was going on here. As soon as I plugged it in, the CPU load disappeared. Unplugged it, and one CPU was busy again.

Trying to figure out what was going on here, I started Resource Monitor and I observed this:

system_irqs

“System Interrupts“ was eating all the CPU time. When I plugged the laptop back again, all was fine and system interrupts was about 1%. Unplugged, 50% again.

I had no idea what could be the cause of this but and idea: I know that sometimes network cards do not like to be sent to sleep and via versa all the time. A friend of mine has a DELL notebook where the network breaks down after the system has a uptime of about two days (he sent the laptop to sleep as I do, so the system is basically always on).

So I started the "Network and Sharing Center, clicked on Change Adapter Settings and disabled the network connection. And the CPU dropped to 1-2%. Enabled it but this time the CPU did not reacted and didn’t go up again.

I plugged the laptop in again, unplugged it but no problems this time. I really seems that sometimes when the laptop is running from battery power the drivers goes nuts and crashes causing the CPU load. By disabling and enabling it again, the drivers starts fresh and everything is fine again. I also checked the driver but neither Intel nor Microsoft had a newer one.

Saturday, October 17, 2009

Windows 7 shared desktop and start menu folders

Although we will switch ASAP from Windows XP to Windows 7, we still have a lot of clients running XP and I think it will takes us up to two years to finally switch the last machine.

One of the problems in the automatic jobs we are using is that Windows 7 has new paths for both the shared desktop and the shared start menu.

As an easy solution for this, we are now using this batch script. It will save the correct path to the two variables DESKTOP_FOLDER and STARTMENU_FOLDER and the real job simply uses them. That way, the scripts works on either XP or Win7.

I know there is a symbolic link “Startmenu” inside \ProgramData in Win7 but some programs refuse to with the link. That’s why I’m using the “real” path here.

IF "%PUBLIC%"=="" GOTO NO_PUBLIC
GOTO PUBLIC_FOUND

:NO_PUBLIC
Rem PUBLIC env var not here, assuming XP
SET DESKTOP_FOLDER=%ALLUSERSPROFILE%\Desktop
SET STARTMENU_FOLDER=%ALLUSERSPROFILE%\Startmenu
GOTO EXEC


:PUBLIC_FOUND
Rem Public Variable found
SET DESKTOP_FOLDER=%PUBLIC%\Desktop
SET STARTMENU_FOLDER=%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu
GOTO EXEC


:EXEC
echo EXEC!
echo Desktop folder is %DESKTOP_FOLDER%
echo Start menu folder is %STARTMENU_FOLDER%

Wednesday, October 7, 2009

Installing Windows 7 drivers from the command line

If a Windows 7 PC with “unknown” (aka Driver missing) will simply connect to Windows Update, check if a matching driver is found and install it. This works fine when using this at home, but it does not work if you are inside a corporate network.

In this case, a Windows Server Update Services (WSUS) is used and it does not contain any drivers. Therefore, you need to manually download the drivers you need, put them in a folder and then use DPinst.exe to install the drivers.

To get this tool, you need to download Windows Driver Kit Version 7.0.0 – a hefty 610 MB download! Burn the ISO image to a CD or open it with WinRAR, and start the setup. Inside the setup, you only need to select “Tools”.

Once the Installation is finished, you can copy dpinst.exe from the \redist\DIFx\dpinst\MultiLin folder:

image

 

 

 

 

Each folder contains a version of DPInst.exe for the architecture the folder is named. I decided to simply rename each version of DPInst.exe and append the architecture to it, so I can copy all version to the same folder.

Create a folder on a network drive, e.g. W7_OnlineDrivers_1 and copy the renamed DPInst.exe files to it. My folder currently looks like this:

image

 

 

 

 

 

What DPInst.exe needs, is DPinst.xml with several settings it (you could also specify them on the command line, but I liked the XML idea more).

<?xml version="1.0" ?>
<dpinst>

<search>
<subDirectory>*</subDirectory>
</search>
<enableNotListedLanguages/>
<suppressEulaPage/>
<quietInstall/>

<!-- Only install drivers for online hardware -->
<scanHardware/>

<!-- No driver signature required -->
<legacyMode/>

</dpinst>

Most settings should be easy to understand, the complete reference can be found on this MSDN page. However, the scanHardware needs some explanation.

If this switch is found inside the file, DPInst.exe will only install drivers that are currently connected to the computer. All other drivers are not installed.

That’s the reason why I called the folder W7_OnlineDrivers. Since it will install only drives that are actually needed on the system, this folder can contain dozens of drivers – drivers that aren't needed will not be installed.

If scanHardware is NOT defined, DPInst.exe will install all drivers, regardless if a device is visible or not. This is basically the same as using pnputil.exe –a C:\<path>\*.inf.

Finally, we need a batch file to start DPInst.exe. I used the following in _install.bat for this:

"%~dp0dpinst_x86.exe" /c
pause

The /c parameter simply indicates that all output should go to the console instead of a log file. That way, you can easily see what is going on. As soon as I have a x64 Test machine ready, I will expand the batch file a little bit so it will execute dpinst_x64.exe on a 64 bit machine and dpinst_x86.exe on a 32 bit machine. For now I stick with the 32 bit version.

Once this is all setup, we are ready to install our first driver. The test computer I currently use had all drivers installed automatically, except for the sound card:

image

 

 

 

 

 

Right click the entry with the yellow exclamation mark and go to the “Details” tab. Inside this, select “Hardware-IDs”. These will list all PCI IDs for the device.

image

 

 

 

 

 

 

 

In this case, VEN_8086 and DEV_2445 should be enough to identify the device, so we will now search Windows Update for a driver:

http://catalog.update.microsoft.com/v7/site/Search.aspx?q=ven_8086%26dev_2445

Please note that this site is using an ActiveX control and therefore you will have to use Internet Explorer. The results of this query should look something like this:

image

Note: Normally you should be able to pick any driver and use it, however the first one I picked (Realtek) contained a file WITHOUT a digital signature and thus DPInst.exe exited with error code 80010300. So, if there is a Microsoft driver available, use it. They always work.

Simply click on the Add button of the driver you are interested in, click on View Basket and download the package, a *.CAB file.

Open the CAB file (with WinRAR for example) and expand all files in it to a new folder inside the W7_OnlineDrivers_1 folder.

Now you can give it a try and execute _Install.bat. If everything has been done right, Windows will install the driver for the sound card and activate it automatically. If not, check the output for any errors.

As a final note: If you download a new driver, just remove the folder containing the old one and execute DPInst.exe again. DPInst.exe will not just install new drivers, it also updates drivers. That’s a great way to keep the drivers current without any extra hassle.

 

UPDATE 2010-12-15: See this post why DPInst sometimes (especially with Network cards) chooses the wrong driver.

Installing and configuring language packs and settings from the command line in Windows 7

The current rollout I’m working on is based on a complete unchanged image from the Windows 7 DVD and several scripts that are running once Windows is installed.

We have done this to make sure that we are always able to update existing installations. That’s simply because it forces us to find the correct commands when Windows is already installed and not working on a WIM image.

One of these things was to install one or more language packs and then reconfigure Windows so it uses a new language (this needs to be done on the command line and not manually of course).

For this, you first need to get the language packs you want to install. Since we are using the Enterprise version of Windows 7, this was easy since there is a separate DVD (mu_windows_7_language_pack_x86_dvd_X15-73272.iso) which contains all language packs.

I simply copied the folders we want to install (de-DE, fr-FR and es-ES) from the DVD to a share. The directory structure then looked like this:

\\swdepot\Win7\LP\de-DE\lp.cab
\\swdepot\Win7\LP\fr-FR\lp.cab
\\swdepot\Win7\LP\es-ES\lp.cab

To install, simple use the lpksetup.exe utility which is included in Windows 7. Executing it with this command:

lpksetup.exe /i * /r /s /p \\swdepot\Win7\LP\

This will install all language packs inside the folder “\LP”.

In order to switch the language, we are using XML files that we basically designed for Vista but still work with Windows 7 (call me lazy…).

To set everything a German user expect (Formats, Location, Language etc.) and to apply the same settings to any new user that logs on, we use the following XML file:


<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!--User List-->
<gs:UserList>
<gs:User UserID="Current" CopySettingsToDefaultUserAcct="true" CopySettingsToSystemAcct="true"/>
</gs:UserList>
<!--User Locale-->
<gs:UserLocale>
<gs:Locale Name="de-DE" ResetAllSettings="true" SetAsCurrent="true"/>
</gs:UserLocale>

<!--Display Language-->
<gs:MUILanguagePreferences>
<gs:MUILanguage Value="de-DE" />
<gs:MUIFallback Value="en-US" />
</gs:MUILanguagePreferences>

<!--location-->
<!-- 0xF4 United States = 244 -->
<!-- 0x5E Germany = 94 -->
<gs:LocationPreferences>
<gs:GeoID Value="94"/>
</gs:LocationPreferences>

</gs:GlobalizationServices>

Most of the settings inside this file should be pretty self-explanatory, but here the link to the detailed explanation: http://www.microsoft.com/globaldev/vista/vista_tools/vista_command_line_international_configuration.mspx


The only “odd” setting inside this file is the “GeoID”. You need to retrieve the matching ID from this page: http://msdn.microsoft.com/en-us/library/ms912389%28WinEmbedded.11%29.aspx

To execute this file use the following command line:

control intl.cpl,, /f:\\swdepot\Win7\Intl_de-DE.xml

To switch back to English, simply replace “de-DE” with “en-US”, set the GeoID to the correct value and apply the new XML file with the command above.

Monday, October 5, 2009

Change Windows Features for Windows 7 / Windows Server 2008 from the command line

In case you want to add or remove feature in Windows 7 or Windows Server 2008 (R2) from the command line, the utility DISM.exe is all you need.

Normally it is used to service WIM images, but it can also execute on “Online” images which means the currently running Windows.

To get a list of features your Windows supports and there state (Enabled or disabled) simply type:

DISM.EXE /Online /Get-Features

To save the output to a file, simply use redirection:

DISM.EXE /Online /Get-Features >C:\Features.txt

To enable (install) a feature use the /Enable-Feature command :

DISM.EXE /online /Enable-Feature /FeatureName:MicrosoftWindowsPowerShellISE

To disable (uninstall) it, use the /Disable-Feature command:

DISM.EXE /online /Disable-Feature /FeatureName:MicrosoftWindowsPowerShellISE

You can enable or disable several features at once:

DISM.EXE /online /Enable-Feature /FeatureName:WindowsServerBackup /FeatureName:WindowsServerBackupCommandlet

However, depending on which feature you change it can happen that one feature requires another so you usually end up having several DISM calls.

In case you want to automate the process fully, add the “/Quiet” parameter but remember that this will restart your computer without any question when necessary:

DISM.EXE /online /Quiet /Enable-Feature /FeatureName:WindowsServerBackup /FeatureName:WindowsServerBackupCommandlet

Sometimes the names in the output of DISM are different from what you see inside the “Turn Windows feature on or off” (Windows 7) or “Add/Remove features” (Server 2008). For example, the IIS feature “Logging Tools” is called “IIS-LoggingLibraries” when using DISM.

To find out how the feature you are searching for is named, simply export the current list of features with this command:

DISM.EXE /Online /Get-Features >C:\Features_Before.txt

Then turn the feature on manually and once the installation is completed, use the following command:

DISM.EXE /Online /Get-Features >C:\Features_After.txt

A simply text compare on these two files will then show which feature has changed its state from “Disabled” to “Enabled”.