Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can a Windows batch script perform the equivalent of a cat until the end of file delimiter (cat > foo << eof)?

35 views
Skip to first unread message

Arlen Holder

unread,
Apr 14, 2020, 5:50:23 AM4/14/20
to
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.


R.Wieser

unread,
Apr 14, 2020, 6:36:15 AM4/14/20
to
Arlen,

> Is this common Linux sequence utilizing an EOF label possible in Windows?

No.

... Which you would have known if you would have tried it yourself.

Regards,
Rudy Wieser


Herbert Kleebauer

unread,
Apr 14, 2020, 8:48:54 AM4/14/20
to
On 14.04.2020 11:50, Arlen Holder wrote:
> 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

I suppose that is not what you really want.

>
> 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

I suppose this is what you want:

@echo off
setlocal enabledelayedexpansion
set t=0
for /f "tokens=*" %%i in ('tzutil /l') do (
set /a t=t+1
set b=!a!
set a=%%i
if !t!==2 (echo REM !b!>"!a!.bat"
echo tzutil.exe /s "!a!">>"!a!.bat"
set t=0))

Arlen Holder

unread,
Apr 14, 2020, 9:34:55 PM4/14/20
to
In response to what Herbert Kleebauer <kl...@unibwm.de> wrote :

> I suppose that is not what you really want.

Hi Herbert Kleebauer,

Thank you for being a purposefully helpful person, with Windows knowledge.

Yes, you are correct in surmising that the ultimate goal is something
anyone can use to make it just a bit more difficult for timezone browser
fingerprinters by randomly switching the system time zone.

Since the system time zone will fluctuate, I've already solved the problem
of displaying a static local time clock on the Windows taskbar which is
completely independent of the system time zone.
o Tutorial for duplicating a Windows taskbar clock in any desired timezone
<https://groups.google.com/d/msg/alt.comp.freeware/LmfYs2a4o0Q/PWjh38zQBwAJ>
Where both the spoofed and actual system time can easily be displayed:
<https://i.postimg.cc/9f6KJx4f/clock02.jpg>

> I suppose this is what you want:

THANK YOU!
o That's perfect!
<https://i.postimg.cc/J0mLXN73/tz02.jpg>

I'm no programmer where I had been struggling in vain using the syntax of
":EOF" labels & "goto :EOF" commands to mimic the cat << EOF capability.

*Your dozen-line script created 137 timezone-setting files*:
@echo off
rem maketzfile.bat
setlocal enabledelayedexpansion
set t=0
for /f "tokens=*" %%i in ('tzutil /l') do (
set /a t=t+1
set b=!a!
set a=%%i
if !t!==2 (echo REM !b!>"!a!.bat"
echo tzutil.exe /s "!a!">>"!a!.bat"
set t=0))
exit 0

*This dozen-line script randomly executes just _one_ of those 137 files:
@echo off
rem setrandomtz.bat
setlocal EnableDelayedExpansion
cd .\tzfiles
set n=0
for %%f in (*.*) do (
set /a n+=1
set "file[!n!]=%%f"
)
set /a num=%random% %% 137-1
"!file[%num%]!"
exit 0

Now all I have to do is figure out how to run that script at random times.
o How do I schedule a task at a random time via batch file?
<https://stackoverflow.com/questions/22941468/how-do-i-schedule-a-task-at-a-random-time-via-batch-file>

That random scheduling solution is hairy, but I can run it manually
by making a shortcut whose target runs the random time zone script above:
TARGET = setrandomtz.bat
STARTIN = c:\path\tzfiles
I can use some of the tricks in this tutorial to make GUI access easy:
o Tutorial to get batch command shortcuts working perfectly on Windows
<https://groups.google.com/d/msg/microsoft.public.windowsxp.general/1PzeGP4KMTU/tTbcd9zxAAAJ>

The only trick left is to figure out how to randomly schedule it to run:
<https://ss64.com/nt/schtasks.html>

THANK YOU very much Herbert Kleebauer, for helping a fellow Windows user!
(And, by extension, helping everyone who wants a random command executor.)
--
Note being able to run a command at a random time which randomly runs one
of 137 timezone commands is, in a general sense, useful, where, in this
case, the goal is to make browser timezone fingerprinting a bit less
uniquely determinative.

Herbert Kleebauer

unread,
Apr 15, 2020, 2:35:22 AM4/15/20
to
On 15.04.2020 03:34, Arlen Holder wrote:

> Now all I have to do is figure out how to run that script at random times.



But why do you create all these batch files? Just do all in a single one:

@echo off
setlocal enabledelayedexpansion

:loop
set /a n=137*%random%/32768*3+1
for /f "tokens=*" %%i in ('tzutil /l^|more +%n%') do set a=%%i& goto :l1
:l1
echo.
echo.
echo setting time zone to: %a%
tzutil.exe /s "%a%"

:: wait 6-24h
set /a n=20864+(%random%*2)
set /a h=%n%/3600
set /a m=(n-(%h%*3600))/60
echo waiting %h% hours, %m% minutes
timeout %n%
goto :loop

Arlen Holder

unread,
Apr 15, 2020, 11:29:32 AM4/15/20
to
In response to what Herbert Kleebauer <kl...@unibwm.de> wrote :

> But why do you create all these batch files? Just do all in a single one:

Hi Herbert Kleebauer,
<https://groups.google.com/d/msg/alt.msdos.batch/azQbz6D_v0Y/AjEBAyveEAAJ>>

Thank you again, on behalf of everyone reading this, now, or well into the
future long after we, ourselves, are long gone for this helpful solution!
<https://i.postimg.cc/5NLJCznK/tz03.jpg>

@echo off
rem tzrandom.bat randomly sets the Windows system timezone
rem by Herbert Kleebauer, 20200415, alt.msdos.batch
setlocal EnableDelayedExpansion

:loop
set /a n=137*%random%/32768*3+1
for /f "tokens=*" %%i in ('tzutil /l^|more +%n%') do set a=%%i& goto :l1
:l1
echo.
echo.
echo setting time zone to: %a%
tzutil.exe /s "%a%"

:: wait 6-24h
set /a n=20864+(%random%*2)
set /a h=%n%/3600
set /a m=(n-(%h%*3600))/60
echo waiting %h% hours, %m% minutes
timeout %n%
goto :loop

exit 0

Your purposefully helpful suggestions to randomly change the Windows
timezone worked perfectly out of the box, and, indeed, is a rather elegant
solution to the stated problem set, which is now happily added to our
Usenet archives as:
<https://groups.google.com/d/msg/alt.msdos.batch/0EE2VwfKwYc/xuiab8zMAAAJ>

Where these are the permanent web-searchable public archives I know of:
o <http://tinyurl.com/alt-msdos-batch>
o <http://tinyurl.com/windowsxp-general> (there is a 30-character limit)
o <http://tinyurl.com/alt-comp-os-windows-10>
And, for posterity & future leverage, at...
o <http://alt.msdos.batch.narkive.com>
o <http://microsoft.public.windowsxp.general.narkive.com>
o <http://alt.comp.os.windows-10.narkive.com>

Yours is a general purpose solution which many can benefit from instantly,
which allows them to add one more level of protection against browser by
raising the randomness of each of our timezone localization fingerprinting!
<https://i.postimg.cc/Gh62bnq0/tz04.jpg>

What's interesting is you consistently correctly surmised a general purpose
solution to the problem set, where, as you noted, there's no need to create
separate timezone command files just to randomly change the system
timezone.
@echo off
rem tzfiles.bat creates named files to set Windows to a given timezone
rem by Herbert Kleebauer, 20200414, alt.msdos.batch
setlocal EnableDelayedExpansion
set t=0
for /f "tokens=*" %%i in ('tzutil /l') do (
set /a t=t+1
set b=!a!
set a=%%i
if !t!==2 (echo REM !b!>"!a!.bat"
echo tzutil.exe /s "!a!">>"!a!.bat"
set t=0))
exit 0

However, to answer your specific question, there is still much value in
creating the 137 timezone files (or 137 shortcuts setting these timezones).
<https://i.postimg.cc/J0mLXN73/tz02.jpg>

This essentially creates an instant easily accessible timezone GUI:
<https://groups.google.com/d/msg/alt.msdos.batch/azQbz6D_v0Y/AjEBAyveEAAJ>

In addition, once we have the 137 timezone command files, at any given
time, a single command can randomly set the timezone out of a smaller
selection of timezone files via this script posted earlier:
@echo off
rem tzset.bat randomly sets Windows timezone based on available files
setlocal EnableDelayedExpansion
cd .\tzfiles
set n=0
for %%f in (*.*) do (
set /a n+=1
set "file[!n!]=%%f"
)
set /a num=%random% %% 137-1
"!file[%num%]!"
exit 0

In summary, both methods have their value, where your purposefully helpful
script can run permanently in the background to set the timezone randomly
(but roughly about every few hours).

And where your wonderful timezone file creation script can be used to
selectively cull the available timezones into a folder for either random
selection, or simply WinXP style cascade menu accordion style selection,
which, I note, never left Windows 10.

There are a few housekeeping chores to tidy up the interface, but the hard
work was done by you such that I thank you for contributing a general
purpose solution for any Windows user to randomly change their timezone to
make it just a little bit harder for browser fingerprinting to work.

Thank you for being a fellow purposefully helpful adult on Usenet!
--
REFERENCES for improving the GUI to switch to random timezones graphically:
o Can windows 10 be made to look like XP?
<https://groups.google.com/d/msg/microsoft.public.windowsxp.general/GIEGzBnB1SA/lvxBoSJaBQAJ>
o Why does anyone bother to install Classic Shell on Windows?
<https://groups.google.com/d/msg/microsoft.public.windowsxp.general/dTHKXIdlqcw/6e7e7dq_AQAJ>
o How can we further IMPROVE the efficiency of the Windows left-side desktop pane?
<https://groups.google.com/d/msg/microsoft.public.windowsxp.general/OoKl4lKrFUc/vw8ozQdkAQAJ>
o Please follow this cut-and-paste tutorial to get batch command shortcuts working perfectly on Windows
<https://groups.google.com/d/msg/microsoft.public.windowsxp.general/1PzeGP4KMTU/tTbcd9zxAAAJ>
o What Windwos freeware adds powerful "phone Susan" & "vipw" commands?
<https://groups.google.com/d/msg/microsoft.public.windowsxp.general/ySVGbayhLSk/zXK3PjijAwAJ>
o Tutorial for setting up a well-organized consistent efficient Windows menu system
<https://groups.google.com/d/msg/microsoft.public.windowsxp.general/eWU-jOkFRtU/lkVU8yolBQAJ>
etc.

Herbert Kleebauer

unread,
Apr 15, 2020, 12:27:40 PM4/15/20
to
On 15.04.2020 17:29, Arlen Holder wrote:

> Hi Herbert Kleebauer,
> <https://groups.google.com/d/msg/alt.msdos.batch/azQbz6D_v0Y/AjEBAyveEAAJ>>

> purpose solution for any Windows user to randomly change their timezone to
> make it just a little bit harder for browser fingerprinting to work.

Do you also use a random name generator?

Arlen Holder

unread,
Apr 15, 2020, 1:42:36 PM4/15/20
to
In response to what Herbert Kleebauer <kl...@unibwm.de> wrote :

> Do you also use a random name generator?

Hi Herbert Kleebauer, (fup only to alt.msdos.batch respected),

I'm sort of openly confused why you ask or even what you are asking.
o Certainly I post tens of thousands of times yearly to the Internet

Each time I strive to add value, collect value, or disseminate value.

My goal on Usenet (and in many web forums) is to add technical value while
maintaining as much privacy, functionality and efficiency as possible.

I've been adding such value in voluminous proportions for decades.

Much of it is privacy based, such as my Windows & Linux threads on how to
set up a privacy-oriented browser strategy to minimize fingerprinting:
o Discussion of two different privacy-related browser philosophies
<https://groups.google.com/d/msg/alt.comp.freeware/H4694--5znY/LOOCa11RBgAJ>

A lot are software based, such as a compilation of full download links:
o Do we have (yet) an actionable list of all free Windows & Linux
web browsers (and the path to the full offline network installers)?
<https://groups.google.com/d/msg/alt.comp.freeware/krNaXA-YEbw/w8QTIPIuBwAJ>

A lot is functionality based, such as this tutorial on Android Studio:
o Report: My first "hello world" using Android Studio freeware
<https://groups.google.com/d/msg/comp.mobile.android/aW64zYeBtF0/1b5h3r3PBAAJ>

Much is cross-platform ease of use, such as this tutorial from yesterday:
o Tutorial: How to connect Android to Windows as a drive letter
over a Wi-Fi LAN for free simple reliable bidirectional copy
<https://groups.google.com/forum/#!topic/comp.mobile.android/9Lu2_dPsu6o>

Yet plenty isn't related to computers at all, e.g., I write up how to
replace an alternator, cooling system, brakes, or clutch, or even how to
mount and balance your own tires at home, as just some examples of adding
value every day of my life.
o Questions about mounting & balancing new LT tires on new steel rims
at home (match mounting marks, red dots, yellow dots, & spacers)
<https://groups.google.com/forum/#!topic/rec.autos.tech/J5-7TxdDpBw>

Most are chock full of well annotated photos, links, references, etc.

Since I add value, oh, tens of thousands of times a year, I strive to
maintain my privacy as much as I can, but I don't go to the level of
changing my vernacular or strategic goals.

I'm not on Usenet for a "chit chat" use model (those people are here merely
for their social amusement); I'm here for only the strategic purpose of:
a. Add value
b. Collect & disseminate value
c. Learn from others

Notice for the chit-chat model, "who" you are is important, far more than
"what you say", whereas in my added-value model, who I am is meaningless as
what matters is what value I have to say.

In summary, I'm confused why you asked the question, where I tried to
answer it in a general sense in that randomization of identifying bits is
always a good thing on the Internet.

Do you have a tool for randomizing more identifying bits while on the net?
o If so, I would love to see if we can make it a general purpose tool.
--
Every Usenet thread should add on-topic technical tribal knowledge value.

Arlen Holder

unread,
Apr 17, 2020, 3:37:09 AM4/17/20
to
SUMMARY:

In this thread, we created a few methods of randomly setting timezones:
o <https://i.postimg.cc/pdV3pJCL/tz01.jpg>

For completeness, we should summarize a few methods of timezone display:
o <https://i.postimg.cc/pdV3pJCL/tz01.jpg>

Namely...
1. Synchronize Windows 10 system time
a. Windows > Settings > Time & Language > Date & time > Related settings >
b. Add clocks for different time zones > Internet Time (tab) >
c. [Change settings...]
d. [x]Synchronize with an Internet time server > Server: time.windows.com

2. Display additional Windows 10 clocks
a. Windows > Settings > Time & Language > Date & time > Related settings >
b. Add clocks for different time zones > Additional Clocks (tab) >
c. [x]Show this clock (Clock 1) > Select time zone > [choose desired tz]
d. [x]Show this clock (Clock 2) > Select time zone > [choose desired tz]

3. Set Windows 10 system time zone
a. Windows > Settings > Time & Language > Date & time > Related settings >
b. Add clocks for different time zones > Date and Time (tab) >
c. Time zone > [Change time zone...] > [choose desired system tz]

Freeware tested:
1. clocx adds a simple but large round desktop clock of a chosen timezone.
<http://www.clocx.net>
2. dsclock adds a configurable desktop digital clock of a chosen timezone.
<http://www.dualitysoft.com>
3. T-clock simply replaces the taskbar clock (same system timezone choice).
<https://github.com/White-Tiger/T-Clock/releases>

If desired, we can modify the taskbar system clock display using freeware:
o T-clock <https://github.com/White-Tiger/T-Clock>
which also has "line spacing" options that dsclock freeware doesn't offer.
<https://windows-cdn.softpedia.com/screenshots/T-Clock-Redux_11.png>
and which has a checkbox option to display the meridiem indicator or not:
<https://windows-cdn.softpedia.com/screenshots/T-Clock-Redux_10.png>
but, as far as I'm aware, T-Clock freeware is bound to the system clock.

Related threads:
o Do you know the font Windows 10 uses for the default Date & Time display?
<https://groups.google.com/forum/#!topic/alt.comp.freeware/LmfYs2a4o0Q>

o Can a Windows batch script perform the equivalent of a cat until the
end of file delimiter (cat > foo << eof)?
<https://groups.google.com/forum/#!topic/alt.msdos.batch/0EE2VwfKwYc>

o What method do you prefer for scheduling a batch file to run silently
[sans a command window displaying]?
<https://groups.google.com/forum/#!topic/alt.comp.freeware/BDv1vWViJ80>

Images for timezones:
o <https://i.postimg.cc/pdV3pJCL/tz01.jpg>
o <https://i.postimg.cc/J0mLXN73/tz02.jpg>
o <https://i.postimg.cc/5NLJCznK/tz03.jpg>
o <https://i.postimg.cc/Gh62bnq0/tz04.jpg>
Images for clocks:
o <https://i.postimg.cc/Dy2mgsNq/clock01.jpg>
o <https://i.postimg.cc/9f6KJx4f/clock02.jpg>
o Font = Segoe UI, semibold, 9, Western
--
Usenet allows purposefully helpful adults to share technical solutions.

Arlen Holder

unread,
Apr 17, 2020, 3:42:45 AM4/17/20
to
In response to what Arlen Holder <arlen...@anyexample.com> wrote :

> In this thread, we created a few methods of randomly setting timezones:
> o <https://i.postimg.cc/pdV3pJCL/tz01.jpg>
>
> For completeness, we should summarize a few methods of timezone display:
> o <https://i.postimg.cc/pdV3pJCL/tz01.jpg>

/Drat. (I accidentally copied the wrong first image). Correction below./

*In this thread, we created a few methods of randomly setting timezones*:
o <https://i.postimg.cc/Gh62bnq0/tz04.jpg>

*For completeness, we should summarize a few methods of timezone display*:
o <https://i.postimg.cc/pdV3pJCL/tz01.jpg>

As always, please improve so all benefit from every action on Usenet.
--
Usenet allows purposefully helpful sharing of facts for common benefit.
0 new messages