CMD and SG 2010 – Part 2.

Planned to do that almost a week ago, but man – it was a crazy week for me. A lot of work, a lot of travelling, a lot of unexpected issues and problems. Fortunately it’s getting peaceful now, so I have a chance to play a bit with Powershell and test tips and tricks I’ve learned during MS 50025 Training. 🙂 Meanwhile it’s time for next two scripts from cmd:

CMD, using GeSHi – Beginner Event 3
  1. @echo off
  2. if not exist C:FSO mkdir C:FSO
  3. pushd C:FSO
  4. >file10.txt echo CLASS:
  5. >>file10.txt echo DATE:
  6. >>file10.txt echo NOTES:
  8. for /l %%N in (1,1,9) do copy file10.txt file%%N.txt > nul

So simple, and yet do what it should. Next one:

CMD, using GeSHi – Beginner Event 4
  1. @echo off
  3.   echo Enough : %NUMBER_OF_PROCESSORS%
  4. ) ELSE (
  5.   echo Not enough : %NUMBER_OF_PROCESSORS%
  6. )

Even simpler. In fact it all started here – while playing with that event in VBS I was thinking: it would be even easier in cmd! And yes, it could be one line of code. I even mentioned it in my comment for SG entry. Judges gave me 2 stars but to be honest – I had no intention to get more. It would be embarrassing to add comments, help and error handling for something THAT simple. And I was shocked with suggestion from expert that if you want to check this in cmd – go grab my 10-line VBS to do so. No way! 😛 I will do it in one line of native cmd code! 😉

Meanwhile I learned new trick for powershell profile. I thought: how nice it would be to have PS window always as big as possible. So I played a bit with $host properties and I managed to get what I want. It was rather simple. See:

PowerShell, using GeSHi
  1. $MySize = $Host.UI.RawUI.MaxPhysicalWindowSize
  2. $MySize.Width –= 3 # We need scrollbar after all… 😉
  3. $MyBuffer = $MySize
  4. $MyBuffer.Height = 5000 # Set to any value you need – I like it looong. 😉
  5. $Host.UI.RawUI.BufferSize = $MyBuffer
  6. $Host.UI.RawUI.WindowSize = $MySize

And last but not least: I entered Powershell Portable beta program and – man – I’m loving it. :> Finally I will be able to carry PS with me to other workstation if I need it. After all not everything can be done via WMI, or even if it’s possible to do something remotely – you won’t have a chance to do that on a computer that has some network issues, right? 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s