-1

I'm writing a script that:
1. Detects which OS it's running on, win10 or win8 (just these two options)
2. Does three Find and Replace-actions
3. starts up the program that belongs to it.
Below is an attempted CMD/DOS batch script:

01    set %versionOS%  to ver
           REM in the above line I want to fill a variable called
           REM %versionOS% with the output of the ver commmand

02    IF  %versionOS% = "Microsoft Windows [Version 10.0.14393]"
           REM in the above line I check if variable
           REM %versionOS% equals "Microsoft Windows [Version 10.0.14393]"

03    command to close an application.
           REM in the above line I want to close an application 
           REM  c:\path\WinCmd.exe this line could be the 1st line too, yes   

04   goto Win10
05        *commmands that change wincmd.ini to one that's suited for Win8
06        (I've figured this one out already)*
07    goto ProgStart
08    :Win10
09         *commmands that change wincmd.ini to one that's suited for Win10*
10   
11    :ProgStart
12     c:\path\WinCmd.exe 

I'd like help with the first 3 lines. Thanks.

1 Answers1

0

Just like in selling houses the three most important things are location, location, location, it seems that in answering questions, the three most important things are motivation, motivation and motivation...apparently. Here's my solution, it works like a charm. Feel free to comment, everything is subject to improvement.. <3 <3 <3

taskkill /im TOTALCMD64.EXE
IF %USERDOMAIN% == GwenKillerby goto Win10
echo win8
    powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'D\:\\', 'QzQ' } | Set-Content f:\totalcmd852\wincmd.ini"    
    powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'C\:\\', 'D:\' } | Set-Content f:\totalcmd852\wincmd.ini"    
    powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'QzQ', 'C:\' } | Set-Content f:\totalcmd852\wincmd.ini"    
    powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace '\\',  '\'   } | Set-Content f:\totalcmd852\wincmd.ini"    
goto ProgStart
:Win10
echo win10
     powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'C\:\\', 'QzQ' } | Set-Content f:\totalcmd852\wincmd.ini"
     powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'D\:\\', 'C:\' } | Set-Content f:\totalcmd852\wincmd.ini"
     powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'QzQ', 'D:\' } | Set-Content f:\totalcmd852\wincmd.ini"
     powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace '\\',  '\'   } | Set-Content f:\totalcmd852\wincmd.ini"
:ProgStart
    f:\totalcmd852\TOTALCMD64.EXE 

(BTW: if anyone can tell me why in 'C\:\\', 'D:\' 'C' needs two slashes while for 'D' one is enough, I'd be so happy.)
First, I tried to make it conditional upon Windows version via a tmpfile which is a more elegant and robust manner.

rem VER > tmpFile
rem set /p myvar= < tmpFile
rem del tmpFile

But I couldn't get it to work, so I used UserWhatever. Also, the output of VER in both Win10 and 8 are virtually identical: Microsoft Windows [6.xxx] versus Microsoft Windows [10.xxx], which means working with those creepy tokens, brrrr!
I'm open to any solution which has less lines or is less complex than. Or, you know, a full PS script/batfile ... ;) ;) ;)