Relevant

A New Template for Joomla!

 

Detect Windows Version Number in Scripts

You can use the "VER" command in your scripts to return the version of Windows that is running.

This is useful when different syntax is required depending on the version. For example, you may want to only run certain commands on Vista and above, because the commands did not exist in XP and Server 2003. You could use the following methods to get the version number, and then use a statement like "IF %_version% is greater than or equal to 6, run the following Vista commands".

To view the version number on the command line

For /f "tokens=4 delims=]\ " %G in ('ver') Do echo %G

To set the version number in a batch file

For /f "tokens=4 delims=]\ " %%G in ('ver') Do (set _version=%%G)

Test the Windows version number in a Kaseya script with an IF statement

In Kaseya scripting you can say "run this step on Vista only" by using the "perform step on" feature. You can select Windows XP, Vista, 7, etc. But you can't say "run this step on Vista and above", which would be very handy! The steps below achieve that. (you can also do things like: run these steps on "Everything before Vista")

New Step:

  • Step Type: Execute Shell Command - Get Results to Variable
  • Shell Command: For /f "tokens=4 delims=]\ " %G in ('ver') Do echo %G
  • Execute as system account

New IF:

  • Condition Type: Check Variable
  • Variable name: #global:cmdresults#
  • Is Greater Than or Equal To: 6

New Step:

  • <stuff to do on Vista and above>

Toggle Else

New Step: 

  • <stuff to do on pre-Vista machines>