Jump to content
Ketarin forum

powershell scripting for version variable


shawn
 Share

Recommended Posts

Apple has abandoned any pretense of including actual version numbers on their site in non-security updates (and - possibly for the first time in history - they actually released an iTunes update that isn't a security update!). This leaves me with no valid external source for the current version number for iTunes. I can get it from the downloaded file after download with FileVer or FSO or from the FileVersion PS property (`[System.Diagnostics.FileVersionInfo]::GetVersionInfo("{file}").FileVersion`). However, I need to cleanly populate this within the {version} variable for my own purposes. I don't mind re-downloading the update every time I check for updates (if I must) but I'd prefer to only download if the file information changes. I've removed the 'check against' variable and Ketarin's native change detection appears to be working perfectly.

I'm now using the following application XML to make it work and parse the version correctly. One caveat: since the version is parsed before the file is completely updated it MIGHT result in the wrong version number being assigned in the version column at first, so I added a script to my post-update script to re-trigger the psversion check so it's properly represented in the column as well as properly pushed in the rest of my after-update script.

Here's the xml:

<?xml version='1.0' encoding='utf-8'?>
<Jobs>
  <ApplicationJob xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Category>Media</Category>
    <WebsiteUrl>https://www.apple.com/itunes/</WebsiteUrl>
    <UserAgent>Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Media Center PC 5.0; SLCC1; Tablet PC 2.0; .NET4.0C)</UserAgent>
    <UserNotes />
    <IgnoreFileInformation>false</IgnoreFileInformation>
    <DownloadBeta>Avoid</DownloadBeta>
    <DownloadDate xsi:nil="true" />
    <CheckForUpdatesOnly>false</CheckForUpdatesOnly>
    <VariableChangeIndicator />
    <HashVariable />
    <HashType>None</HashType>
    <CanBeShared>true</CanBeShared>
    <ShareApplication>false</ShareApplication>
    <ExclusiveDownload>true</ExclusiveDownload>
    <HttpReferer>https://www.apple.com/itunes/download</HttpReferer>
    <SetupInstructions />
    <Variables>
      <item>
        <key>
          <string>version</string>
        </key>
        <value>
          <UrlVariable>
            <RegexRightToLeft>false</RegexRightToLeft>
            <VariableType>Textual</VariableType>
            <TextualContent>{psversion:ps}</TextualContent>
            <Name>version</Name>
          </UrlVariable>
        </value>
      </item>
      <item>
        <key>
          <string>sdownload</string>
        </key>
        <value>
          <UrlVariable>
            <RegexRightToLeft>false</RegexRightToLeft>
            <VariableType>Textual</VariableType>
            <TextualContent>https://www.apple.com/itunes/download/win64</TextualContent>
            <Name>sdownload</Name>
          </UrlVariable>
        </value>
      </item>
      <item>
        <key>
          <string>psversion</string>
        </key>
        <value>
          <UrlVariable>
            <RegexRightToLeft>false</RegexRightToLeft>
            <VariableType>Textual</VariableType>
            <Regex />
            <TextualContent>[System.Diagnostics.FileVersionInfo]::GetVersionInfo("{file}").FileVersion</TextualContent>
            <Name>psversion</Name>
          </UrlVariable>
        </value>
      </item>
    </Variables>
    <ExecuteCommand />
    <ExecutePreCommand />
    <ExecuteCommandType>Batch</ExecuteCommandType>
    <ExecutePreCommandType>Batch</ExecutePreCommandType>
    <SourceType>FixedUrl</SourceType>
    <DeletePreviousFile>true</DeletePreviousFile>
    <Enabled>true</Enabled>
    <TargetPath>..\{category}\{appname:regexreplace:([\s\t\r\n\-\&amp;]+):_}-{version}.{url:ext}</TargetPath>
    <FixedDownloadUrl>{sdownload}</FixedDownloadUrl>
    <Name>iTunes (x64)</Name>
  </ApplicationJob>
</Jobs>

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.