How to convert a batch script in ruby

Hi All,

I am new to ruby and currently working on a batch file which needs to
be converted into ruby.

The batch code is
wmic pagefileset list | findstr /i /c:“c:”>nul
if not {%errorlevel%}=={0} set NoPagingFileC=true&goto
for /f "tokens=1-10 delims= " %%a in (‘wmic pagefileset list ^|
findstr /i /c:“c:”’) do (
set CurrentInitialPagingFileSizeMBC=%%d
set CurrentMaximumPagingFileSizeMBC=%%e
set CurrentPagingFileC=%%f
if defined CurrentPagingFileC (
for /f “tokens=1-10 delims=” %%a in (‘echo %CurrentPagingFileC%’)
do set CurrentPagingFileCwmic=%%a\%%b

I am trying to convert this code into ruby. with only little experience
in ruby, I am able to transform only some portion of code

def find_current_paging_fileSettingsC?‘wmic pagefileset list | findstr /i /c:“c:”’)
puts cmd.stdout[0]
if cmd.exitstatus != 0
puts “NoPagingFileC setting to true”

if find_current_paging_fileSettingsC?

how to implement GOTO. here I would like to go to another function
how to handle for condition here!!!
Please suggest any other better option to do.


Just define the method named FindCurrentPagingFileSettingsP(), then call
it. That simple.