Saturday, October 30, 2010

Optimising Battery

Hi

Whilst preparing my media for a long haul flight I have coming up recently, I wanted to make sure I got every last drop of energy out of my laptop battery before it ran out.

What I wanted to do was have a script which closed all applications which are not required to run. All I want is to be able to watch VLC, but I have a number of programs which are running in the background on startup e.g. Dropbox. Obviously this is no use to me on a plane so why leave it running and have it wasting CPU resource?

I first of all found this useful article at Lifehacker for quitting all applications


The second thing I wanted this script to do was to change the power management profile to my super battery saving mode. Windows 7 gives you loads of options to tweak this how you see fit.

I used the powercfg command to set the profile. More details on this can be found here


Lastly I wanted to pin this in the taskbar. In Windows 7 you cannot pin batch files to the taskbar. There are lots of ways around this, I used the following


So my script is as follows (replace username with actual username and GUID of power management profile which is relevant to you)

#battery optimiser
powercfg -s df011ed9-9131-49b9-8090-46963cfb65ce
C:\Windows\System32\taskkill.exe /F /FI "USERNAME eq username" /FI "IMAGENAME ne explorer.exe" /FI "IMAGENAME ne dwm.exe"

The shortcut I created just had explorer.exe preceed it to make sure it could pin to the taskbar

C:\Windows\explorer.exe "C:\Users\username\My Dropbox\Personal\Battery Optimiser.bat"

Some really useful information here and you can tweak it quite a lot to suit you.

Cheers!

Sam

Friday, October 29, 2010

Monday, October 04, 2010

Create XenDesktop 4 administrator through MFCOM

Hello there

XenApp 6 removes MFCOM and replaces it with a full set of powershell SDKs which make scripting tasks far easier to complete.

I was asked to create a script to add a Citrix Administrator for a XenDesktop 4. This was actually easier than I had initially thought. The complexity with this task revolves around the granularity that Citrix administrators have with XenApp. Fortunately there are only a couple of options to configure for XenDesktop.

The below powershell script adds the user administrator from the domain SAMO2 to be a full administrator. To change this to a Delegated administrator change AdminType to 2.

$mfFarm = New-object -com "MetaframeCOM.MetaFrameFarm"
$mfFarm.Initialize(1)
$newadmin=$mfFarm.addadmin()
$newadmin.AccountName = "Administrator"
$newadmin.AccountType = 2
$newadmin.AAName = "SAMO2"
$newadmin.AAType = 3
$newadmin.Enable = 1
$newadmin.AdminType = 3
$newadmin = $newadmin
$newadmin.savedata()

Cheers

Sam