2017-04-14 5 views
-1

ファームウェアバージョンが11.500.11.13の形式を11.500.12.13にアップグレードする場合は、システム情報とファームウェアのバージョンをダンプするサンプルバッチファイルを作成します または11.500.15.13、そして、私はそのルールに従っていることを確認する必要があります。 以下のバッチファイルはどのように編集できますか?自動ファームウェアチェックを開始するバッチファイルを作成しています

@echo off 
    >"info.txt" systeminfo.exe 
    >"log.txt" netsh mbn show interfaces 
    >"result.txt" (
     findstr /l /i /c:"System Model:" /c:"OS Version" "info.txt" 
     findstr /l /i /c:"Model" /c:"Firmware Version" "log.txt" 
    ) 
del/f "info.txt" "log.txt" 

答えて

0

あなたはFirmware Versionラインの形式またはバージョン番号が先行ゼロを含めるかどうかを私たちに語っていません。

あなたは

@ECHO OFF 
SETLOCAL 
SET "sourcedir=U:\sourcedir" 
SET "filename1=%sourcedir%\q43404681.txt" 
SET "filename2=%sourcedir%\q43404681_2.txt" 
FOR /f "delims=" %%a IN ('FINDSTR /i /L /c:"Firmware Version" "%filename1%"') DO SET "firmware=%%a" 

FOR /f "tokens=1-4delims=." %%a IN ("%firmware:*Firmware Version=%") DO (
FOR /f "usebackqtokens=1-4delims=." %%p IN ("%filename2%") DO (
    SET "newer=" 
    IF %%p gtr %%a SET "newer=Y" 
    IF %%p equ %%a IF %%q gtr %%b SET "newer=Y" 
    IF %%p equ %%a IF %%q equ %%b IF %%r gtr %%c SET "newer=Y" 
    IF %%p equ %%a IF %%q equ %%b IF %%r equ %%c IF %%s gtr %%d SET "newer=Y" 
    IF DEFINED newer ECHO Upgrade: %%p.%%q.%%r.%%s 
) 
) 

GOTO :EOF 

、その後、バージョン番号はフォーム

xxxxのファームウェアバージョン11.500.11.13

のものであり、自分の番号付けスキームは、先行ゼロを含んでいないだろうと仮定すると、状況に応じてsourcedirの設定を変更する必要があります。

テストのためにいくつかのダミーデータを含むq43404681.txtという名前のファイルを使用しました。

私はこの結果を示した私のテストのために、このデータを含むq43404681_2.txtという名前のファイル(利用可能なソフトウェアバージョンのリスト)

11.500.11.10 
11.500.11.13 
11.500.11.15 
11.500.12.7 
11.500.12.13 
11.500.15.9 
11.500.15.13 
11.511.1.1 
12.100.6.22 

使用:

アップグレード:11.500.11.15
アップグレード:11.500.12.7
アップグレード:11.500.12.13
アップグレード:11.500.15.9
アップグレードデ:11.500.15.13
アップグレード:11.511.1.1
アップグレード:12.100.6.22

firmwareFirmware versionラインを分離したので、我々は文字列firmware version:*サブストリング演算子を使用して、任意の前の文字を削除することができます。次に、.をデリミタとして使用し、結果として得られる4つのトークンを%%a .. %%dに選択します。

%%p .. %%sへの使用可能なオプションのリストについては、まったく同じ引数です。単純に階層を使用してバージョン番号を比較し、すべて数字の引数をアルファベット順ではなくネメリックに比較するif-operator特性をxxxと比較するだけです。変数newerは、利用可能な各バージョンが読み取られ、後のバージョンがif論理によって検出された場合に値(それは問題ではない)に設定されるとクリアされるフラグとして使用される。

if defined命令は、ifコマンドのいずれかによってi newerが設定された変数の実行時値に作用するため、アップグレード行が再現されます。


@ECHO Off 
SETLOCAL 
SET "sourcedir=U:\sourcedir" 
SET "filename1=%sourcedir%\q43404681.txt" 
SET "filename2=%sourcedir%\q43404681_2.txt" 

REM ^^^^^^ These lines simply set up the filenames to be used 

FOR %%a IN (osversion,systemmodel,biosversion,model,firmwareversion) DO SET "#%%a=" 

REM now we have cleared the variables to be used all of which begin "#" 

FOR /f "delims=" %%a IN ('type "%filename1%"') DO (
FOR /f "tokens=1,2,* delims=: " %%p IN ("%%a") DO (
    IF "%%p%%q"=="OSVersion" SET "#osversion=%%r" 
    IF "%%p%%q"=="SystemModel" SET "#systemmodel=%%r" 
    IF "%%p%%q"=="BIOSVersion" SET "#biosversion=%%r" 
    IF "%%p%%q"=="FirmwareVersion" SET "#firmwareversion=%%r" 
    IF "%%p"=="Model" FOR /f "tokens=1,* delims=: " %%v IN ("%%a") DO SET "#model=%%w" 
) 
) 

SET # 

REM This should have extracted the required data fields 
REM The last "SET" is simply to display their values and can be deleted 

REM You can now display whatever of these values you choose. 

REM IF "filename2" contains a list of the possible firmware versions 
REM available as in the list "11.500.11.10" to "12.100.6.22" 
REM then this following routine should show all available versions 
REM which are newer than the version installed according to your report 


FOR /f "tokens=1-4delims=." %%a IN ("%#firmwareversion%") DO (
FOR /f "usebackqtokens=1-4delims=." %%p IN ("%filename2%") DO (
    SET "newer=" 
    IF %%p gtr %%a SET "newer=Y" 
    IF %%p equ %%a IF %%q gtr %%b SET "newer=Y" 
    IF %%p equ %%a IF %%q equ %%b IF %%r gtr %%c SET "newer=Y" 
    IF %%p equ %%a IF %%q equ %%b IF %%r equ %%c IF %%s gtr %%d SET "newer=Y" 
    IF DEFINED newer ECHO Upgrade: %%p.%%q.%%r.%%s 
) 
) 

GOTO :EOF 

Perhaps you should use google translate to convert the remarks in the above program to your language. The first block for instance translates to

IF "filename2"には、使用可能なファームウェアのバージョンのリストが含まれています リスト「11.500.11.10」から「12.100.6.22」のように利用可能 この次のルーチンは利用可能なすべてのバージョンを表示する必要があります あなたのレポートに従ってインストールされたバージョンより新しい

or

IF“filename2”包含可能的固件版本列表 可用于“11.500.11.10”至“12.100.6.22” 那么以下例程应显示所有可用的版本 它们比根据您的报告安装的版本更新

(sorry - It looks like Chinese to me - I can't tell the difference)

+0

I'm sorry - that response makes no sense :( – Magoo

+0

I have add some problem below your answer, very thanks your help!!! –

+0

@Magoo The first translated text is in Japanese, while the second one is in Chinese(simplified)... – SteveFest

関連する問題