In a bash script I write for creating a config file for dosbox, I can define the Current Resolution:
#!/bin/bash
#
if [ "$Resolucion" = "1152x864" ]; then
windowresolution=$(echo windowresolution=1024x768)
scaler=$(echo scaler=2xsai)
fi
Full script is available here.
In bash I can make
echo '
Line 1
Line 2
Line with Varible 1 fullResolution='"$Resolucion"'
Line with Varible 2 '"$windowresolution"'
Line with Varible 3 '"$output"'
Line with Varible 4 '"$scaler"'
Lines :
@echo off
mount c '"$Ruta_Actual/.$Titulo"'
c:
'"$Ejecutable"'
exit' | tee "$PWD/dosbox.conf" &> /dev/null
Now I need to do the same in a batch script, but I don't know how make batch + VBScript working.
I wrote the following for testing purposes:
@echo off
setlocal enabledelayedexpansion
color A
title BattleChess
set DIR="%CD%"
set PWD=%CD%\Juegos\Inukaze\BattleChess
set TITULO="BattleChess"
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo strComputer = "." >> %SCRIPT%
echo Set objWMIService = GetObject("winmgmts:" _ >> %SCRIPT%
echo & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") >> %SCRIPT%
echo Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor") >> %SCRIPT%
cscript /nologo %SCRIPT%
for /F %%* in (%SCRIPT%) do set RES=%%A
echo %RES% >> %CD%\RES.TXT
The RES.TXT just have a %A in it, but I can get the current resolution with this VBScript:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor")
For Each objItem in colItems
msgbox( "Current Resolution : " & objItem.ScreenWidth & "x" & objItem.ScreenHeight)
Next
However, I don't know how to make a file %CD%\dosbox.conf with multiples lines and using the "Current Resolution" from VBScript.
The lines of VBScript show me an error.
The Error :
""{impersonationLevel=impersonate}\\"" is not recognized as an internal or external command, program or batch file.
"strComputer" is not recognized as an internal or external command,
program or batch file.
The system can not find the path specified.
Well i dont know how to export the script .
But the answer :
for /F %%A in (
'wmic desktopmonitor get ScreenHeight^,ScreenWidth /value ^| find "="'
) do set "%%A"
set "RES=%ScreenWidth%x%ScreenHeight%"
echo %RES%
That solves that for me.
OK, this almost ready, I just need to know how I can make the following from bash script:
# Resolutions 4:3
if [ "$Resolucion" = "640x480" ]; then
windowresolution=$(echo windowresolution=512x384)
scaler=$(echo scaler=2xsai)
fi
if [ "$Resolucion" = "800x600" ]; then
windowresolution=$(echo windowresolution=640x480)
scaler=$(echo scaler=2xsai)
fi
if [ "$Resolucion" = "1024x768" ]; then
windowresolution=$(echo windowresolution=800x600)
scaler=$(echo scaler=2xsai)
fi
if [ "$Resolucion" = "1152x864" ]; then
windowresolution=$(echo windowresolution=1024x768)
scaler=$(echo scaler=2xsai)
fi
into batch script. I really don't know if the next are right:
REM "Resolutions 4:3"
if %RES% = 800x600
set windowresolution=640x480
set scale=2xsai
I need specify multiple resolutions and windowresolutions in the script for better config file.
echo "lines" >> %CONFIG%
echo "%variable%" >> %CONFIG%
which I need use for each
"if %RES%=Numbers X Numbers"
windowresolution=%WINRES%
scale=something
to export to the config file the follow
Resolution=800x600
windowresolution=640x480
scale=2xsai
echo hello & worldexecutes asecho hellofollowed byworldgiving you ""world" is not a command..." You have to escape some chars (like&) with a caret.echo hello ^& worldwill print "hello & world"