Category Archives: Technology - Page 2

Windows Phone 8 on older hardware

I was reading this morning about the previews of Windows Phone 8 starting to make rounds and the one thing that draw my attention was the things mentioned about older hardware that won’t be supported by the new OS. I have an older ‘first generation’ WMP7 phone (HTC Mozart) that I use as a backup phone so it would have been nice if it was possible to upgrade to WMP8 – but unfortunately MS is greedy and wants us to buys more hardware (that has all the royalties and licenses built in) that makes them even more money.

One interesting thing mentioned in a techreport article is that there will be an upgrade to WMP7 to version 7.8 that will superficially look like the new OS (but many features missing of course). Hopefully this could help until I have the opportunity to upgrade my phone at the end of this year or so.

 

Microsoft announce tablet

I have to admit, the general feeling towards Windows 8 is still not a positive one – definitely if you look at it from a desktop/productivity perspective. BUT, seeing the pictures of the newly announced Microsoft tablets there may be some hope for Microsoft/Windows – as long as you are in the ‘tablet’ or consumer market. They are to be branded ‘Surface’ or Microsoft boutique multi-touch tablets. Looks awsum! (but then these are marketing pictures…)

Microsoft tablet

Microsoft tablet (shamelessly copied from techreport site 😉 )

One positive feature of both (yes that’s right two) models is the battery life. The ARM (NVidia) based one has something like a 31 watt-hour battery while the Intel one has 42 watt-hour. If that is true these little machines would really be nice for people that are always on the move. The Intel model features a full HD display while the ARM model has an expansion slot (Micro HD). Both models include an detachable ‘soft’ keyboard. Storage is not in the PC arena but still a useful 32 or 64GB on the ARM model and 64/128GB on the Intel one.

Keyboard choices

Keyboard choices

On a slightly negative side they only have USB 2.0 ports (not 100% sure about the Intel one) plus only the ARM model includes a copy of Office. The tablets will be sold in Microsoft ‘stores’ thus meaning it won’t be available in our beloved S of A. Our only option would be to try to buy it online or smuggle one in with a friend that was visiting the US of A.

Well, good luck Microsoft, perhaps there is some hope for ya.

Update: apparently the Intel based version does have USB 3.0. Nice.

Creating daily log files

In the (wild) old days when the only thing we had to work with computers were the command line we use to store output of important processes to a (text)file so it can be viewed and worked on afterwards. Event today in a support and administration environment these skills are very handy.

The process of doing this was/is called ‘output direction’ or ‘pipe output to’ since the standard output ‘device’ was the console (command window). So taking the application output away from the console meant redirecting it to a ‘file’ – since in a sense the ‘console’ could also be seen as a file that gets stuff outputted to (a temporary one).

Anyway, say you want to save the output of a command line utility like ‘dir’ to a file – you would use the following:

dir *.txt > dir.txt

All this does is execute the normal ‘dir *.txt’ command but store the output to the file ‘dir.txt’. This only outputs the standard ‘console output’ to the text file. If the output file already exists it gets overwritten. Actually there are two types of ‘standard outputs’: 1 – the normal successful and 2 – the standard error output. Using only the ‘>’ operator is just a shortcut for ‘1>’ which only outputs the ‘standard successful’ output i.e. the previous example is the same as:

dir *.txt 1> dir.txt

The second type of output is the ‘standard error’ output. To get this output you use the ‘2>’ operator e.g.

Someexe.exe 2> errors.txt

If you want to combine the outputs – that is both normal and error outputs you can use this:

Someexe.exe > errors.txt 2>&1

Lets say you want to keep a history of all previous outputs – then you want to use the ‘append’ operator ‘>>’:

Someexe.exe >> output.txt

If the file ‘output.txt’ does not exist yet it will be created. Otherwise and new output will simply be appended. If you want to combine all of these – that is combine normal and error ouputs plus append to the output file you can use this:

Someexe.exe >> output.txt 2>&1

Now, say you want to use part of the date when creating, listing etc. files. Unfortunately this tip depends on the date-time format settings of the machine you are running it on. For my example I use the ‘yyyy/mm/dd‘ format. To get the year you can use the following:

set year=%date:~0,4%

To get the month you can use ‘%date:~5,2%’ or day ‘%date:~8,2%’ – again this only works for the ‘yyyy/mm/dd’ format. If your date-time format is different you have to change the ‘~x,y‘ parts where x is ‘from’ and y is ‘to’ character positions.

Now using the example above you can use:

dir %year%*.txt

to file all files with a name that start with the current year (e.g. 2012blablabla.txt)

You can use the same technique when creating output files, e.g.

dir *.txt > %year%List.txt

This way you can create daily log files e.g.

set year=%date:~0,4%
set month=%date:~5,2%
set day=%date:~8,2%
Someexe.exe >> %year%%month%%day%.log

Mission accomplished… for now.

Launch apps as Admin without prompt

This is a tip intended to ease the pain of continuously having to click the ‘Yes’ prompt when you want to launch an app in ‘Admin mode’.

The trick is to use the built-in Windows Task scheduler.

1. First you create a new task (not a basic task) and specify a name e.g. ‘CommandLine’ plus check the ‘Run with highest privileges’ check box.

2. On the actions tab you add a ‘Start a program’ action and select the executable e.g.’C:\Windows\System32\cmd.exe‘

3. Optionally under the Settings tab you can choose ‘Run a new instance in parallel’so you can run multiple instances of the app if required.

4. Click OK to create the task

Next you create a Windows shortcut (say on the desktop by right clicking and choosing new -> Shortcut)

1. Specify the following as the ‘Target’: e.g.  ‘C:\Windows\System32\schtasks.exe /run /tn CommandLine‘
Pay attention that the last parameter must match the task name.

2. You may want to manually select an icon for the shortcut as it won’t select the app icon by itself.

Now if you click (double-click) the shortcut a brief command line window before opening your app (in admin mode) – without prompting you! One big disadvantage is that you cannot pass command line parameters this way so launching say notepad with a specified txt file this way won’t work.

Of course, it would have been easier if MS built in a way you can choose (at your own risk) which apps you would like to launch in admin mode without prompting. There is a potential security risk in allowing functionality like that but if they wanted to it could be done with a big warning dialog at the start – that tells you you’re doing this at your own risk. It could use something like signing the required exe with a local (only) certificate to mark it trusted only on the local machine or generating a hash that gets stored in an encrypted system location or something, to tell the OS that particular exe can be trusted (when launched). The way to set up this hash and stuff would need to be a secure process in itself (requiring a ‘human’ user input) and letting you jump through a couple of hoops – once off. The idea is to allow only that particular exe on the particular machine as trusted. Copying it to another machine or changing it would require setting up the ‘trust’ again. Just an idea… (throwing a hint… to Microsoft)

Phone cameras

First off, I’m no super expert on cameras or optics but this is something that bugs me about all these ‘photographers’ that think their phone is a super camera.

These days just about every phone out there – even the cheapies, have some camera built in. The trouble is they are all pretty much useless for doing real photography. The reason is pretty simple – physics (or more specifically – optics).

You can have a super camera sensor but if the lens is not good the output picture will still be crappy. The opposite is you can have an average sensor with a good lens and your pictures should be good. Why? The reason is simple – a good picture requires more photons/light – plain and simple. The tiny lenses on all camera phones make it impossible to generate a really good picture. This is still one area in ‘life’ where bigger ‘is’ better. The bigger surface area you have to capture photons/light the better. Ask astronomers why they keep on building bigger and bigger telescopes despite all the progress in other areas of technology. You need to capture more light to get a better picture – especially if you want to zoom in and crop. Of course, the bigger the lens the more difficult it is to make it.

I still have an old Canon S3-IS which is ‘only’ a 6 megapixel camera but its pictures are still better than any of my modern camera phone pictures (which has something like 8MP sensor). As explained above the sensor size has little to do with the picture quality (within reason). The only real advantage of a phone camera is that I’m more likely to have tit close by most of the time – oppose to my bigger cameras.

The same basically applies to things like tablets – like the iPad and so on. Basically any device that has a ‘little’ peephole camera will have the same issue.

All I can do when I see one of these ‘modern day’ photographers is to smile…

The big wheel of progress

Lots of things follow the big turning wheel of success/failure through time. Sometimes you go up and other times down. Take share prices and/or market share in the IT industry. There was a time (some many moons ago) that Microsoft was soaring high among the clouds but lately it has been skimming the ground and loosing altitude with every flap of their (cripple) wings.

As if being passed by Apple in many market segments aren’t bad enough it now seems another old ally/opponent is passing it by in its way up – The big Blue company – IBM. Reading a post on Ars technica showing a few graphs about share prices over the last decade (or two) it is clear Microsoft is on the downward side of the big wheel of business.
Looking at the graph (below) some interesting events can be seen (like launch of Windows 95/Vista/7). However, the general direction of the ‘Microsoft’ graph is not an ‘upward’ one – oppose to Apple/IBM. It remains to be seen if Microsoft as a company can change this with new products like Windows 8/Phone/Tablet stuff. The perceived position of the company isn’t that of great strength – looking at the management as seen from outside. That doesn’t mean that Microsoft is totally doomed but the shareholders should be starting to worry (if they aren’t already hehe). A lot will ride on Windows 8 as a product and as a new direction for the once monolithic desktop OS company. There is always a chance that history can repeat itself and Microsoft can fight from humble/small beginnings to cover the majority of (a/the) market. Trouble is just that they have more than one powerful adversary this time (not just IBM). This time there are Apple and Google as well. Things certainly are not as simple as in the 80’s…Borrowed from Ars Technica… shamelessly.

 

 

Creating a self installing Windows Service

Being in the business of creating several Windows Services myself (EventScavenger, Event Collector, QuickMon) I started thinking about how to make the whole install and set up process a bit easier and eliminating the manual steps to install a Windows Service.

So what if you can simply run the service ‘exe’ with a “-install” or “-uninstall” parameter and let it do the work for you? Additionally, what if it it can even prompt you for start up type and user account details during the process – all of this without even using installutil…?

Well after some research, testing, trail and error, losing some more hair and eventually finding a way to make it work I now have a way to do all this. Nice thing is it can be used together with an MSI installer as well or even an external app or script.

ProjectInstaller

The trick is to create a custom ProjectInstaller class (not use the wizards that comes with VS to add installers). I’ve added some properties to this class to specify things like Service name, display name, start up type, account type, user name and password.

[RunInstaller(true)]
public class ProjectInstaller : Installer
{

private ServiceProcessInstaller processInstaller;
private System.ServiceProcess.ServiceInstaller serviceInstaller;

#region Added properties
public string ServiceName
{
get { return serviceInstaller.ServiceName; }
set { serviceInstaller.ServiceName = value; }
}
public string DisplayName
{
get { return serviceInstaller.DisplayName; }
set { serviceInstaller.DisplayName = value; }
}
public string Description
{
get { return serviceInstaller.Description; }
set { serviceInstaller.Description = value; }
}
public ServiceStartMode StartType
{
get { return serviceInstaller.StartType; }
set { serviceInstaller.StartType = value; }
}
public ServiceAccount Account
{
get { return processInstaller.Account; }
set { processInstaller.Account = value; }
}
public string ServiceUsername
{
get { return processInstaller.Username; }
set { processInstaller.Username = value; }
}
public string ServicePassword
{
get { return processInstaller.Password; }
set { processInstaller.Password = value; }
}
#endregion

public ProjectInstaller()
{

processInstaller = new ServiceProcessInstaller();
serviceInstaller = new System.ServiceProcess.ServiceInstaller();

Installers.AddRange(new Installer[] {
processInstaller,
serviceInstaller});

}

protected override void OnBeforeInstall(System.Collections.IDictionary savedState)
{

SetContextParameter(“name”, ServiceName);
SetContextParameter(“display”, DisplayName);
SetContextParameter(“desc”, Description);
SetContextParameter(“start”, StartType.ToString());
SetContextParameter(“account”, Account.ToString());

if (Account == ServiceAccount.User)
{

SetContextParameter(“user”, ServiceUsername);
SetContextParameter(“password”, ServicePassword);

}
base.OnBeforeInstall(savedState);

}

public void SetContextParameter(string key, string value)
{

if (!this.Context.Parameters.ContainsKey(key))

this.Context.Parameters.Add(key, value);

else

this.Context.Parameters[key] = value;

}

}

Calling the Installer/uninstaller

In order to get the service executable to handle the -“install” or “-uninstall” parameters I modified the Main method in Program.cs to accept a string parameter array and then call the appropriate method if either of those two parameters are passed.

Example code:

static class Program
{

static void Main(string[] args)
{

if (args.Length > 0)
{

if (args[0].ToUpper() == “-INSTALL”)
{

InstallService();
return;

}
else if (args[0].ToUpper() == “-UNINSTALL”)
{

UnInstallService();
return;

}

}
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] { new SelfInstallService() };
ServiceBase.Run(ServicesToRun);

}

private static bool InstallService()
{

bool success = false;
try
{

string exeFullPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string workingPath = System.IO.Path.GetDirectoryName(exeFullPath);
string logPath = System.IO.Path.Combine(workingPath, “Install.log”);
ServiceStartMode startmode = ServiceStartMode.Automatic;
ServiceAccount account = ServiceAccount.LocalService;
string username = “”;
string password = “”;

InstallerForm installerForm = new InstallerForm();
installerForm.StartType = ServiceStartMode.Automatic;
installerForm.AccountType = ServiceAccount.User;
if (installerForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{

startmode = installerForm.StartType;
account = installerForm.AccountType;
if (installerForm.AccountType == ServiceAccount.User)
{

username = installerForm.UserName;
password = installerForm.Password;

}

}

Hashtable savedState = new Hashtable();
ProjectInstaller myProjectInstaller = new ProjectInstaller();
InstallContext myInstallContext = new InstallContext(logPath, new string[] { });
myProjectInstaller.Context = myInstallContext;
myProjectInstaller.ServiceName = “SelfInstallService”;
myProjectInstaller.DisplayName = “Self Install Service”;
myProjectInstaller.Description = “Self Install Service test”;
myProjectInstaller.StartType = startmode;
myProjectInstaller.Account = account;
if (account == ServiceAccount.User)
{

myProjectInstaller.ServiceUsername = username;
myProjectInstaller.ServicePassword = password;

}
myProjectInstaller.Context.Parameters[“AssemblyPath”] = exeFullPath;

myProjectInstaller.Install(savedState);
success = true;

}
catch (Exception ex)
{

System.Windows.Forms.MessageBox.Show(ex.Message, “Install service”, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);

}
return success;

}

private static bool UnInstallService()
{

bool success = false;
try
{

string exeFullPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string workingPath = System.IO.Path.GetDirectoryName(exeFullPath);
string logPath = System.IO.Path.Combine(workingPath, “Install.log”);

ServiceInstaller myServiceInstaller = new ServiceInstaller();
InstallContext Context = new InstallContext(logPath, null);
myServiceInstaller.Context = Context;
myServiceInstaller.ServiceName = “SelfInstallService”;
myServiceInstaller.Uninstall(null);
success = true;

}
catch (Exception ex)
{

System.Windows.Forms.MessageBox.Show(ex.Message, “Uninstall service”, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);

}
return success;

}

}

You might notice I use a custom form ‘InstallerForm’ here which I’m not showing the code for. All it is is a simple Windows Form that allows you to enter or choose some settings that this code is using. I’ll upload some code example a bit later.

Now, you can simple go to the command line (or create a batch file) that calls the service exe with either the “-install” or “-uninstall” parameters.

Update: I’ve added some sample code here. There have been some improvements since the article. It turns out the overridden method OnBeforeInstall is not necessary at all.

In a new blog post I’ve enhanced the functionality to include multi instance functionality. See this.

Firefox 7

And there they release 7. So far can’t see any major differences as far as I’m concern (other than a few broken add-ins which hasn’t been updated)

Post PC world

I read somewhere this morning (one of the RSS feeds from techreport.com) about someone (not pointing fingers) that made another claim that we are going into the ‘post-pc’ world… Right, I almost burst out in loud laughter!

Definition

So what exactly is a ‘personal computer’? Or more specifically, what do you understand from the words ‘personal’ and ‘computer’? Surely anything that has computing power – like a classical ‘PC’, smart phone, tablet, laptop, abacus 😉 etc. and is a personal ‘possession’ can be classified as a ‘personal computer’… sorta. Yes, even that fancy stupid little iPad/iPhone etc falls under that description. Actually, it is just another iteration of the ‘personal computer’ idea. Nothing more. Move along fruity fanboys.. 🙂

Conclusion

The conclusion I can make about these statements (like mentioned in the first paragraph) is that it is merely a ‘sales’ pitch from someone trying to sell or market something they will get some benefit from. Period.

Desktop computer

Now here is a device that may be becoming a bit ‘old’. But I doubt it will disappear anytime soon. All we really still need from them is to be able to ‘verbally’ respond back to our commands… er wait, that is my 2051 comment for pc’s… Anyway, Don’t always believe what those sales/marketing crooks tell ya. All they really want is your money!

Windows 8 – A couple of follow-up thoughts

I must admit I haven’t done extreme testing or anything hectic with it yet but there are a couple of irritating things about the Windows 8 Developer Preview. Hopefully these will only be issues that is due to the ‘test/beta’ status of Windows 8 and that they improve some things along the way.

At the moment I have two big’ish issues with the Developer Preview.

1. The Metro interface – I don’t have an actual problem with it as such except that you don’t have the option to easily disable it and return to the more classical Windows 7 desktop. It may be great for tablets or other portable devices with touch screens but not on a work related PC – and definitely not for legacy applications.

2. Internet connectivity is absolutely required – Not everyone has super fast and uncapped connections – even today. For me the problem is even worse because I have to run it inside a VM (VirtualBox) on a network where it is not allowed to have such test stuff accessing the Internet. The problem it creates is that this developer preview ‘absolutely’ requires a connection even to do something as simple as adding Windows components (through the add/remove programs control panel). Why it has to go to the Windows Update site just to get something that should be on the local install media is beyond me!

On the positive side I’m really impressed with the boot-up speed. General performance/response is really good (yes, even inside a VM). I only have 2GB memory allocated to it and it doesn’t feel too sluggish – but yes, I’m not running any hectic applications inside it.