コンピューターにインストールされている特定のプログラムのテキストドキュメントをスキャンしており、スキャンしている文字列に大なり小なりの変数を含める簡単な方法を探しています。これは私が現在使用しているものの非常に醜くて面倒な例であり、一時的な修正として機能しますが、実用的でも持続可能でもありません。
If CheckBox2.Checked Then
sReader.Close()
If text.Contains("Adobe Flash Player 11 Plugin") And
text.Contains("Adobe Flash Player 11 ActiveX") Then
Else
If text.Contains("Adobe Flash Player 12 Plugin") And
text.Contains("Adobe Flash Player 12 ActiveX") Then
Else
If text.Contains("Adobe Flash Player 13 Plugin") And
text.Contains("Adobe Flash Player 13 ActiveX") Then
Else
'(Goes ahead and does a silent install of the missing or outdated program)
これまでのところ、AdobeFlashとJavaRTEの両方でこの問題が発生しており、将来のプログラムでも問題が発生することは間違いありません。基本的に、「Adobe Flash Player(11未満の任意の数)プラグイン」、「Adobe Flash Player(11未満の任意の数)ActiveX」、「Java(9未満の数)更新(任意の数)」をスキャンする必要があります。
提供されているソリューションは、後で遭遇する可能性のある同様のプログラムに適応できる可能性が高いと確信しています。ありがとう
- - - 編集 - - -
それ以来、次のコードを試しましたが、スキャンしているファイルにAdobe Flashのバージョンが存在しない場合でも、常に「Found」メッセージボックスが返されます。
If CheckBox2.Checked Then
sReader.Close()
Dim options As RegexOptions = RegexOptions.None
Dim regex As Regex = New Regex("Adobe Flash Player (?<version>\d+) (Plugin|ActiveX)", options)
Dim input As String = "Adobe Flash Player 11 Plugin"
' Get match
Dim match As Match = regex.Match(input)
Dim version As String = match.Groups("version").Value
If (match.Success) Then
MessageBox.Show("Version 11 or higher found, skipping install")
Else
MessageBox.Show("Version 11 or higher not found, installing Version 11")