View Single Post
  #1  
Old April 14th 20, 10:50 AM posted to alt.msdos.batch,alt.comp.os.windows-10,microsoft.public.windowsxp.general
Arlen Holder[_7_]
external usenet poster
 
Posts: 141
Default Can a Windows batch script perform the equivalent of a cat until the end of file delimiter (cat foo eof)?

Is this common Linux sequence utilizing an EOF label possible in Windows?
cat "foo1.bat" EOF
command 1 to go into the batch file
command 2 to go into the batch file
EOF

cat "foo2.bat" EOF
command 3 to go into the batch file
command 4 to go into the batch file
EOF

For an instantly understandable example of "why" you might want this,
consider the Windows timezone utility being used to create 137 unique batch
files named to Windows time-zone standards, as defined by:
tzutil.exe /l list-of-time-zone-commands.txt
Such that those 137 batch files can be used to randomize the system clock
(e.g., to forestall browser fingerprinting based on time-zone id bits).
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/tzutil

Clarifying (for only 2 of those 137 batch files) the goal would be to
utilize the EOF tag similar to how it would be used below:
cat "Eastern Standard Time.bat" EOF
REM (UTC-05:00) Eastern Time (US & Canada)
tzutil.exe /s "Eastern Standard Time"
EOF

cat "Pacific Standard Time.bat" EOF
REM (UTC-08:00) Pacific Time (US & Canada)
tzutil.exe /s "Pacific Standard Time"
EOF

Note: For WindowsXP, the "tzutil" command is substituted by something like:
runDLL32.exe shell32.dll,Control_RunDLL timedate.cpl,,/Z (GMT-5:00) Eastern
runDLL32.exe shell32.dll,Control_RunDLL timedate.cpl,,/Z (GMT-8:00) Pacific

Windows commands that could create the 137 tz randomizer files are many:
https://www.computerhope.com/issues/ch001676.htm
http://www.trytoprogram.com/batch-file-commands/
https://www.robvanderwoude.com/batchcommands.php
etc.

*But how can we tell Windows batch files to stop output at the EOF tag?*
--
Usenet is a place for adults to gather to politely discuss solutions.


Ads