Thursday, April 22, 2010

getting .net on Windows 2008

http://dmitrysotnikov.wordpress.com/2008/05/15/powershell-on-server-core/

“Group cannot be specified along with other identification conditions.”

“Group cannot be specified along with other identification conditions.”
Windows Server Core 2008 R2
While using server core yesterday I came across another interesting error. I was attempting to update a firewall rule and I kept receiving this error:
“Group cannot be specified along with other identification conditions”
I double checked my spelling and syntax and everything looked right. Take a look at the picture below, can you see my mistake?

It turns out it was actually a pretty dumb issue, but an easy one to overlook. I had copy and pasted the command in from a webpage, and the quotes must have been Microsoft Word style quotes. I deleted the quotes, re-ran the command, and success! It’s a minor issue that was easy to overlook. In this case it was quick to find and fix, but it reminded me of the days when I searched for an error in my .NET code only to see that two single quotes ” looked like one ” double quote character. It took forever to find the error because everything appeared right, but of course it wasn’t.

Monday, April 19, 2010

Set Desktop Wallpaper according to screen Resolution

Recently I had a strange problem in our organisation.
We had Windows 7 Ent workstations with Windows 2003 Domain with soem restrictive GPOs.
One of them is company wallpaper through GPO. The GPO setting works fine but there was a strange problem. Some of the workstations appeared to be black background. The wallpaper is set, can se the filename with path in Destop Preferences, but does'nt appearing, unless you select Fit/Fill/Stretch/Center any on of them. This setting can be set from GPO but if it works on standard resolution then does'nt works on widescreen or vice versa. But if i use the wallpaper with the same resolution then works fine, but does'nt looks fine on other widescreen looks.
After some disgnosis i found that we have basically two types of screen size one Widescreen and other standard. But the wallper i was using in GPO was widescreen and higher resolution than max resolution supported by screens.
The problem was how to set by GPO to check resolution and set the wallpaper accordingly.
The solution i found was to write a script and set at logon by GPO which will detect the resolution and set the wallpaper accordingly.
I took help from Internet to write this code, so i had release to internet in return.

It is writen in vbscript to use run cscript script-name.vbs or set by GPO

I had kept the background images at a location named according to resolution like bg-1024.jpg, bg-1280.jpg, bg-1440.jpg ___________________________________________________________________
Dim strComputer
strComputer = "."

' Prepare WMI Connection
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

' Query WMI
Set getPixelsWidth = objWMIService.Execquery("Select * from CIM_VideoController")

' Get the Horizontal Resolution
strPixelWidth = getPixelsWidth.ItemIndex(0).CurrentHorizontalResolution

' Prepare filename for background wallpaper
strWallPaper = "\\x.x.x.x\usrdata\commonfiles\bg-" & strPixelWidth & ".jpg"

' Setting the wallpaper
Dim strWallPaper
Dim wshShell
Dim sUserName

Set wshShell = WScript.CreateObject("WScript.Shell")
sUserName = wshShell.ExpandEnvironmentStrings("%USERNAME%")

Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")

sWinDir = oFSO.GetSpecialFolder(0)
sWallPaper = strWallPaper

' update in registry
oShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper

' let the system know about the change ( looped few times as always does'nt work first time )
For i = 0 to 15
oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", True
wscript.echo i
Next
___________________________________________________________________
Best Regards.

Wednesday, April 14, 2010

The Man Who Survived Two Atomic Bombs


Tsutomu Yamaguchi was, depending on your point of view either the luckiest man on Planet Earth of exactly the opposite. Either way, what happened to him in the August of 1945 is nothing short of amazing – and his survival miraculous.

Yamaguchi was a resident of Nagasaki but on the fateful day of 6 August 1945 he was in Hiroshima, on business for his employer, Mitsubishi. He was badly wounded when the bomb carried by Enola Gay exploded above Hiroshima but survived and returned to Nagasaki the next day.

Amazingly, he returned to work on August 9 – most of us in this day and age will take a day off work if we have a nosebleed, let alone get blown up by an atomic bomb. He was explaining the first bomb to his supervisor when Bocks Car flew over Nagasaki. The Fat Man atomic bomb was dropped on to the city and Tamaguchi became the victim of a second atomic blast. He was three kilometers away from Ground Zero but was not able to get treatment for the injuries he had received in Hiroshima – for obvious reasons.

He was recognised as a hibakashu (one of those affected by the explosions) but only of the Nagasaki bomb – he kept his remarkable story to himself for many years. The Japanese government finally recognised his presence in both cities in 2009. He died of stomach cancer in January 2010.

We may not have heard the last of Tsutomu Yamaguchi. Several months before his death he met the film director James Cameron (of Titanic and Avatar fame). It seems that the director is keen to shoot Yamaguchi’s story – and it certainly does deserve more exposure. Let’s just hope that Celine Dion doesn’t sing the theme music.