Welcome to MSFN

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


Sign in to follow this  
Followers 0
ricktendo

Help make CMD install on XP x86 only

20 posts in this topic

OK so I have this .net aio installer I want to make only install on XP x86, it already has code for it to skip if run on Windows 2000 I would like to use something similar for XP64/Vista*/7*/8* and above

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::                                                        ::::     Installer created by yumeyao with strel's help     ::::                                                        ::::               WaitNET.exe by RogueSpear                ::::                                                        ::::                  Script created with                   ::::         Silent .NET Maker synthesized 20090913         ::::  http://www.msfn.org/board/index.php?showtopic=127790  ::::                                                        ::::         Script modified by yumeyao on 20091023         ::::      Script remodified by ricktendo64 on 20100817      ::::                                                        ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONSET VERBOSITY=/quiet&SET VERBOSITYSHORT=/qnIF "%1"=="/qn" SET VERBOSITY=/quiet&SET VERBOSITYSHORT=/qnIF "%1"=="/quiet" SET VERBOSITY=/quiet&SET VERBOSITYSHORT=/qnIF "%1"=="/silent" SET VERBOSITY=/silent&SET VERBOSITYSHORT=/qnIF "%1"=="/qb" SET VERBOSITY=/passive&SET VERBOSITYSHORT=/qbIF "%1"=="/qb!" SET VERBOSITY=/passive&SET VERBOSITYSHORT=/qbIF "%1"=="/passive" SET VERBOSITY=/passive&SET VERBOSITYSHORT=/qbIF NOT EXIST FILEVER.vbs (    ECHO>>FILEVER.vbs Set objFSO = CreateObject^("Scripting.FileSystemObject"^)    ECHO>>FILEVER.vbs Wscript.Echo objFSO.GetFileVersion^(WScript.arguments^(0^)^))FOR /F "DELIMS=. TOKENS=1" %%I IN ('CSCRIPT //NOLOGO FILEVER.vbs "%SYSTEMROOT%\SYSTEM32\MSI.DLL"') DO IF /I "%%I"=="2" (    IF /I "%VERBOSITY%"=="/passive" SET VERBOSITY=/qb!    IF /I "%VERBOSITY%"=="/silent" SET VERBOSITY=/qn    IF /I "%VERBOSITY%"=="/quiet" SET VERBOSITY=/qn)SET SYS2K=1IF EXIST %SYSTEMROOT%\system32\reg.exe (    SET SYS2K=    FOR /F "DELIMS=" %%I IN ('%SYSTEMROOT%\system32\REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName') DO ECHO>DNFWIN1.TXT %%I    FOR /F %%I IN ('FINDSTR/I "2000" DNFWIN1.TXT') DO SET SYS2K=1)IF DEFINED SYS2K GOTO:SYSTEM2KFOR /F "TOKENS=3" %%I IN ('REG QUERY "HKLM\SYSTEM\Setup" /v SystemSetupInProgress') DO SET SSIP=%%IIF /I "%SSIP%"=="0x1" (    SET SSIPAFTERFIX=NO    REG QUERY "HKLM\SOFTWARE\Microsoft\PCHealth\ErrorReporting\DW"    IF NOT ERRORLEVEL 1 SET SSIPAFTERFIX=YES&REG EXPORT "HKLM\SOFTWARE\Microsoft\PCHealth\ErrorReporting\DW" SSIPFIX.REG&REG DELETE "HKLM\SOFTWARE\Microsoft\PCHealth\ErrorReporting\DW" /f    REG ADD "HKLM\SYSTEM\Setup" /v SystemSetupInProgress /t REG_DWORD /d 0 /f)IF EXIST *.TXT DEL /F *.TXTFOR /F %%I IN ('DIR/B DNF30\SYS32') DO (    XCOPY/DY DNF30\SYS32\%%I %SYSTEMROOT%\SYSTEM32    %SYSTEMROOT%\SYSTEM32\REGSVR32 /S %SYSTEMROOT%\SYSTEM32\%%I)START /WAIT DNF40\netfx_core_x86.msi /UPDATE "%CD%\DNF40\kb2468871.msp" %VERBOSITY% /norestartSTART /WAIT WaitNET.exe %VERBOSITYSHORT%START /WAIT DNF40\netfx_Extended_x86.msi /UPDATE "%CD%\DNF40\kb2468871.msp" %VERBOSITY% /norestartSTART /WAIT WaitNET.exe %VERBOSITYSHORT%START /WAIT DNF20\netfx20a_x86.msi VSEXTUI=1 ARPNOMODIFY=1 ARPNOREPAIR=1 TRANSFORMS=MUFIXES20.MST REBOOT=ReallySuppress %VERBOSITY%START /WAIT WaitNET.exe %VERBOSITYSHORT%START /WAIT DNF30\netfx30a_x86.msi VSEXTUI=1 ARPNOMODIFY=1 ARPNOREPAIR=1 TRANSFORMS=REMFONTCACHEFIX.MST;MUFIXES3035.MST %VERBOSITY% /norestartSTART /WAIT WaitNET.exe %VERBOSITYSHORT%START /WAIT DNF35\vs_setup.msi VSEXTUI=1 ARPNOMODIFY=1 ARPNOREPAIR=1 TRANSFORMS=MUFIXES3035.MST %VERBOSITY% /norestartSTART /WAIT WaitNET.exe %VERBOSITYSHORT%START /WAIT DNF11\netfx.msi TRANSFORMS=NETFX11SP1.MST %VERBOSITY% /norestartSTART /WAIT WaitNET.exe %VERBOSITYSHORT%START /WAIT WaitNET.exe %VERBOSITYSHORT% /eIF /I "%SSIP%"=="0x1" (    IF "%SSIPAFTERFIX%"=="YES" REG IMPORT SSIPFIX.REG    REG ADD "HKLM\SYSTEM\Setup" /v SystemSetupInProgress /t REG_DWORD /d 1 /f)GOTO:EOF:SYSTEM2KECHO This version of dotnet cannot be installed on Windows 2000.ECHO>%SYSTEMROOT%\DOTNET5IO.TXT This version of dotnet cannot be installed on Windows 2000.

Thanks for your time

 

0

Share this post


Link to post
Share on other sites

Since Windows version number 5.1 indicates XP, then I believe you should be able to simply change this:

 

...SET SYS2K=1IF EXIST %SYSTEMROOT%\system32\reg.exe (    SET SYS2K=    FOR /F "DELIMS=" %%I IN ('%SYSTEMROOT%\system32\REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName') DO ECHO>DNFWIN1.TXT %%I    FOR /F %%I IN ('FINDSTR/I "2000" DNFWIN1.TXT') DO SET SYS2K=1)IF DEFINED SYS2K GOTO:SYSTEM2K...:SYSTEM2KECHO This version of dotnet cannot be installed on Windows 2000.ECHO>%SYSTEMROOT%\DOTNET5IO.TXT This version of dotnet cannot be installed on Windows 2000.
to:

 

SET "_OSV=" & FOR /f "TOKENS=2 DELIMS=[]" %%G IN ('VER') DO FOR /f "TOKENS=2,3 DELIMS=. " %%H IN ("%%~G") DO SET "_OSV=%%H.%%I"IF NOT "%_OSV%."=="5.1." GOTO:NOTXP...:NOTXPECHO This version of dotnet can only be installed on Windows XP.ECHO>%SYSTEMROOT%\DOTNET5IO.TXT This version of dotnet can only be installed on Windows XP.
EDIT: See posts below about missing "%" marks :)

Cheers and Regards

Edited by bphlpt
0

Share this post


Link to post
Share on other sites

Thanks... Do you know if XP x64 is also v5.1

0

Share this post


Link to post
Share on other sites

Hi rickendo,

 

XP x64 is v5.2 as mentioned here.

 

Perhaps this recent topic here about getting Windows versions may also help since your 1st post mentions many OSes.

0

Share this post


Link to post
Share on other sites

According to this:
 


XP x64 and 2003 is 5.2, but to make absolutely positive you could always include an extra test:
 

SET "_MyArch=x64" & IF %PROCESSOR_ARCHITECTURE%==x86 IF NOT DEFINED PROCESSOR_ARCHITEW6432 SET "_MyArch=x86"IF "%_MyArch%"=="x64" GOTO:NOTXP

EDIT: See posts below about missing "%" marks :)

but it shouldn't be necessary. Test it for sure yourself, of course.

Cheers and Regards

Edited by bphlpt
0

Share this post


Link to post
Share on other sites

To further differentiate XPx64 from Win2003, the following REG_SZ registry value can be checked. I'm sorry I don't have the time to write a proper CMD line to do so...

HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType"
"WinNT" = XP

"ServerNT" = Win2003

0

Share this post


Link to post
Share on other sites

Thanks guys for all the help, I think I will use first code

Edited by ricktendo
0

Share this post


Link to post
Share on other sites

For anyone that is interested in this i used this simply code a long time ago in a batch script.

@ECHO OFFIF NOT "%Processor_Architecture%" == "x86" GOTO IncorrectOSver | find "5.1." 1>NUL && GOTO CorrectOS || GOTO IncorrectOS:CorrectOSECHO Executing Windows Calculator...START "" /WAIT "%WinDir%\system32\calc.exe"PAUSEEXIT:IncorrectOSECHO This dotNET AIO Pack can only be installed on Windows XP 32-bit.PAUSEEXIT
Edited by Jeffery
0

Share this post


Link to post
Share on other sites

First code not working, always skips... Here is the output

E:\Projects\Installers\dotNetFx_AIO_x86>SET "_OSV="   & FOR /F "TOKENS=2 DELIMS=[]" %G IN ('VER') DO FOR /F "TOKENS=2,3 DELIMS=. " %H IN ("%~G") DO SET "_OSV=%H.%I" E:\Projects\Installers\dotNetFx_AIO_x86>FOR /F "TOKENS=2,3 DELIMS=. " %H IN ("Versi¢n 5.1.2600") DO SET "_OSV=%H.%I" E:\Projects\Installers\dotNetFx_AIO_x86>SET "_OSV=5.1" E:\Projects\Installers\dotNetFx_AIO_x86>IF NOT "_OSV." == "5.1." GOTO:NOTXPE:\Projects\Installers\dotNetFx_AIO_x86>ECHO This version of dotnet can only be installed on Windows XP. This version of dotnet can only be installed on Windows XP.E:\Projects\Installers\dotNetFx_AIO_x86>ECHO This version of dotnet can only be installed on Windows XP. 1>C:\WINDOWS\DOTNETAIO.TXT
0

Share this post


Link to post
Share on other sites

What about something like this instead?

FOR /F "TOKENS=2 DELIMS=[]" %%A IN ('VER') DO FOR /F "TOKENS=3 DELIMS=." %%B IN ("%%A") DO IF %%B NEQ 2600 GOTO :NOTXP
0

Share this post


Link to post
Share on other sites

What about something like this instead?

FOR /F "TOKENS=2 DELIMS=[]" %%A IN ('VER') DO FOR /F "TOKENS=3 DELIMS=." %%B IN ("%%A") DO IF %%B NEQ 2600 GOTO :NOTXP
Works like a charm!
0

Share this post


Link to post
Share on other sites

Hey Rick,

I think the code was always skipping because you wrote the test as:

IF NOT "_OSV." == "5.1." GOTO:NOTXP

instead of:

IF NOT "%_OSV%."=="5.1." GOTO:NOTXP

EDIT: See posts below about missing "%" marks :)

and batch is sometimes VERY particular about extra spaces, especially in string tests, which this one was. To test this, and since it seems you do not need to keep the value of "_OSV" for any other reason, would you mind substituting these two lines, in separate tests, for the one Yzöwl suggested to see if either of them would also would work? (Which one, or that of Yzöwl, you end up using is completely up to you of course. I think they should all give the same result based on your tests above.)

FOR /f "TOKENS=2 DELIMS=[]" %%G IN ('VER') DO FOR /f "TOKENS=2,3 DELIMS=. " %%H IN ("%%~G") DO IF NOT "%%H.%%I"=="5.1" GOTO:NOTXP...or...FOR /f "TOKENS=2 DELIMS=[]" %%G IN ('VER') DO FOR /f "TOKENS=2,3 DELIMS=. " %%H IN ("%%~G") DO IF %%H.%%I NEQ 5.1 GOTO:NOTXP

EDIT: Yzöwl code included for easy reference:

FOR /F "TOKENS=2 DELIMS=[]" %%A IN ('VER') DO FOR /F "TOKENS=3 DELIMS=." %%B IN ("%%A") DO IF %%B NEQ 2600 GOTO :NOTXP

Cheers and Regards

Edited by bphlpt
0

Share this post


Link to post
Share on other sites

There are also the missing exclamation marks to consider:

IF NOT "_OSV."=="5.1." GOTO:NOTXP
...should be...

IF NOT "!_OSV!."=="5.1." GOTO:NOTXP
Edited by 5eraph
0

Share this post


Link to post
Share on other sites

Well D@mn, [ stupid, stupod, stoopid me! :)  Corrected posts above.]  Thanks 5eraph, though since the IF was not in a FOR loop or nested in any way I think it should have been:
 

IF NOT "%_OSV%."=="5.1." GOTO:NOTXP

 
and not exclamation marks, right?
 
NOTE:  This correction should not effect the last suggested test I made to Rick, since _OSV was not used.
 
Cheers and Regards

Edited by bphlpt
0

Share this post


Link to post
Share on other sites

and not exclamation marks, right?

 

Since ENABLEDELAYEDEXPANSION is explicited, that won't make a difference.

 

jaclaz

0

Share this post


Link to post
Share on other sites

But it should make a difference, jaclaz. Using % instead of ! gives only the initial value for the variable, not the most recent one. ;)

Edited by 5eraph
0

Share this post


Link to post
Share on other sites

But it should make a difference, jaclaz. Using % instead of ! gives only the initial value for the variable, not the most recent one. ;)

You would be correct 5eraph, if the variable usage had been inside a FOR loop, but not if it is just consecutive statements, unless I'm not understanding what you mean. In other words:

@ECHO OFFSETLOCAL ENABLEDELAYEDEXPANSIONSET "_OSV=1"SET "_OSV=2"SET "_OSV=3"SET "_OSV=4"SET "_OSV=5"SET "_OSV=6"SET "_OSV=7"SET "_OSV=8"SET "_OSV=9"SET "_OSV=0"SET "_OSV=" & FOR /f "TOKENS=2 DELIMS=[]" %%A IN ('VER') DO FOR /f "TOKENS=2,3 DELIMS=. " %%B IN ("%%~A") DO SET "_OSV=%%B.%%C"ECHO= _OSV=%_OSV%ECHO= _OSV=!_OSV!

will output two lines of the same thing -- _OSV=5.1 (or whatever the value is for your OS)

Cheers and Regards

0

Share this post


Link to post
Share on other sites

Yep, that's the idea behind delayed expansion. (though the name is IMHO counterintuitive, as with delayed expansion on and ! you get the "current" value, whilst with % you get the value it had "before" entering the FOR loop).

 

See if this other source is more clear:

http://www.robvanderwoude.com/variableexpansion.php

 

jaclaz

0

Share this post


Link to post
Share on other sites

@5eraph, I absolutely love ss64.com, and robvanderwoude.com as well, for batch reference, but you probably misinterpreted the two special case examples given the first thing on your ss64 source page.
 
I might not be wording this completely right, but I'll try.  The key to remember is that without delayed expansion enabled, and/or variables using %, each batch statement is parsed and evaluated in its entirety with the value of the % variables as they were just before the statement was executed.  In the first example:

Set _var=firstSet _var=second& Echo %_var% !_var!

The second line, and any other time that multiple statements are connected with & or || or &&, is considered to be ONE batch statement which is why %_var% and !_var! will have different values when delayed expansion is enabled.  As jaclaz said, ' with delayed expansion on and ! you get the "current" value, whilst with % you get the value it had "before" '. The same is true with a FOR loop, or IF THEN, or any other collection of statements enclosed in parentheses, regardless if it is multi-line or all on one line. That is one batch statement, no matter how many lines are involved, that is parsed completely before it is executed.

The second example is even trickier, but it basically is a way of escaping a redirection, and other characters that would normally "screw up" a batch command by trying to cause an action, to be able to use batch to work with HTML and XML statements.
 
You can find another explanation of EnableDelayedExpansion here - http://blogs.msdn.com/b/oldnewthing/archive/2006/08/23/714650.aspx

Hope that helps.

Cheers and Regards

Edited by bphlpt
0

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.