A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Microsoft Windows XP » General XP issues or comments
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

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



 
 
Thread Tools Display Modes
  #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
  #2  
Old April 14th 20, 11:36 AM posted to alt.msdos.batch,alt.comp.os.windows-10,microsoft.public.windowsxp.general
R.Wieser
external usenet poster
 
Posts: 1,302
Default Can a Windows batch script perform the equivalent of a cat until the end of file delimiter (cat foo eof)?

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


  #3  
Old April 14th 20, 01:48 PM posted to alt.msdos.batch,alt.comp.os.windows-10,microsoft.public.windowsxp.general
Herbert Kleebauer
external usenet poster
 
Posts: 27
Default Can a Windows batch script perform the equivalent of a cat untilthe end of file delimiter (cat foo eof)?

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))
  #4  
Old April 15th 20, 02:34 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)?

In response to what Herbert Kleebauer 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.
  #5  
Old April 15th 20, 07:35 AM posted to alt.msdos.batch,alt.comp.os.windows-10,microsoft.public.windowsxp.general
Herbert Kleebauer
external usenet poster
 
Posts: 27
Default Can a Windows batch script perform the equivalent of a cat untilthe end of file delimiter (cat foo eof)?

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

  #6  
Old April 15th 20, 04:29 PM 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)?

In response to what Herbert Kleebauer 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.
  #7  
Old April 17th 20, 08:37 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)?

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 freewa
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.
  #8  
Old April 17th 20, 08:42 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)?

In response to what Arlen Holder 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.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off






All times are GMT +1. The time now is 01:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.