Can this batch file damage/prevent Windows 10 from booting?

Is there any chance, anything in the following batch could possibly delete/damage/corrupt any useful Windows 10 files (drivers, registry or other useful components), to the point of preventing them from even starting and causing a bootloop?

Caution: Don’t run this code as it might damage your system

takeown /f "H:PVR" /r
icacls "H:PVR" /reset /T
FOR /R "H:PVR" %%i IN (*.ts *.tsv) DO MOVE "%%i" "H:PVR"
CD /D "H:PVR"
ren *.tsv *.ts
for /f "delims=" %%d in ('dir /ad /b') do @rd /q /s "%%d"
setlocal EnableDelayedExpansion
for %%a in (*.ts *.tsv) do (
   set name=%%~Na
   set num=00!random!
   set newName=!!name:~-17!
   ren "%%a" "!newName!%%~Xa"
)

It’s a batch file I put together combining several commands found here and other places, in order to process .ts recodings from my DVBT-T2 receiver, stored in a flash drive.
The idea is to:

a). Take permission for the “H:PVR” and all its contents (the PVR folder in my flash drive).

b). Take the .tsv recordings out of the subfolders, then delete those subfolders.

c). Rename .tsv extension to .ts

d). Remove the first 17 characters from the filenames (cause I don’t like the prefix format of my receiver).

Please note I ran the batch file (as admin) both from the flash drive AND my C: drive, where Windows are installed. Then a CMD window opened and I saw filenames which are not in my flash drive being processed which was fishy….
My code skills are bad and I am trying to learn by adapting, but I never throught I could create a Frankenstein code that could do that. Please go ahead and tell me I’ve done something so foolish, I will be actually VERY HAPPY to hear so, because it’s the second time within 10 days that I am getting a nasty bootloop (no instant BSOD btw, but after running the bat file, ever since the next reboot, Windows won’t start and display “Critical Service Failed”), and I’ve been trying hard to troubleshoot it, to no avail. Bonus points for letting me know what’s the mistake and how to correct it, but just letting me know whether it could be responsible is also absolutely fine!

Please tell me it’s not a coincidence. Thank you.

windows command prompt – I need to rename a file and insert a date

I’m trying to set a daily process to locate a file, rename it and insert the previous date in the file name. I want the file to be named “Filename_MMddyyyy.csv” with MMddyyyy being the previous day. I managed to rename the file but I’m a total noob and I don’t know how to calculate the previous day date and insert it in the file name. Here is what I managed to do so far:

cd C:

set file= “pathtomyfile*.CSV”
if exist %file% (
ren “pathtomyfile*.CSV” “Filename.CSV”
)

Thank you very much in advance.

docker – Cannot gather stats and Invalid template file after installing Porto theme

After setting up Magento 2 in developer mode, I am getting a couple of errors:

(2021-04-19 21:39:09) report.INFO: Broken reference: the 'yotpo_bottomline' tries to reorder itself towards 'product.info.addto', but their parents are different: 'product.info.main' and '' respectively. () ()
(2021-04-19 21:39:09) report.CRITICAL: Cannot gather stats! Warning!stat(): stat failed for /app/pub/static/frontend/Magento/luma/en_US/mage/requirejs/mixins.js {"exception":"(object) (Magento\Framework\Exception\FileSystemException(code: 0): Cannot gather stats! Warning!stat(): stat failed for /app/pub/static/frontend/Magento/luma/en_US/mage/requirejs/mixins.js at /app/vendor/magento/framework/Filesystem/Driver/File.php:95)"} ()
(2021-04-19 21:39:10) report.CRITICAL: Invalid template file: 'owl_list.phtml' in module: 'Smartwave_Filterproducts' block's name: 'homefeaturedlist_0' {"exception":"(object) (Magento\Framework\Exception\ValidatorException(code: 0): Invalid template file: 'owl_list.phtml' in module: 'Smartwave_Filterproducts' block's name: 'home\featuredlist_0' at /app/vendor/magento/framework/View/Element/Template.php:280)"} ()
(2021-04-19 21:39:10) report.CRITICAL: Invalid template file: 'grid.phtml' in module: 'Smartwave_Filterproducts' block's name: 'homefeaturedlist_1' {"exception":"(object) (Magento\Framework\Exception\ValidatorException(code: 0): Invalid template file: 'grid.phtml' in module: 'Smartwave_Filterproducts' block's name: 'home\featuredlist_1' at /app/vendor/magento/framework/View/Element/Template.php:280)"} ()

I followed the Magento 2 documentation to install Magento in docker. Then, in an attempt to follow the Porto docs, I copied the Porto theme files, the theme patch for Magento 2.2.x, theme patch for Magento 2.3.x, and the theme patch for Magento 2.4.1.

Any help on resolving the above errors would be appreciated.

java – Counting the number of unique IP addresses in a very large file. Follow-Up #1

It’s a follow-up question.
A previous version
of this code has been posted on Code Review about 2 weeks ago.

What was done after the last review

In fact, the entire application is rewritten from scratch. Here
is current version with tests and JavaDoc.

I tried to split the application into small classes that have only one responsibility and can be re-used and extended.

The main approach to solve a problem has not changed. I still put one value in accordance with each ip and set a bit with the corresponding index in the bit array. The required amount of memory remained the same about 550-600 MB. The speed has increased, now I am practically limited to the performance of my hard disk. It is still assumed that only valid IPs will be in the file.

I deleted all JavaDoc comments from code examples, because they occupy more space than the code itself.

FixedSizeBitVector

I wrote a simple implementation of the bit array that allows you to store N bits with indexes from 0 to N-1. There are
three operations are supported: set bit, examine bit’s value, and get the number of all the set bits.
getCapacity() method used for testing and may be useful in other cases.

I do not bring the BitVector interface due to its primitiveness and simplicity.

package chptr.one;

public class FixedSizeBitVector implements BitVector {

    public static final long MIN_CAPACITY = 1L;
    public static final long MAX_CAPACITY = 1L << 32;

    private final long capacity;
    private final int() intArray;
    private long cardinality;

    public FixedSizeBitVector(long capacity) {
        if (capacity < MIN_CAPACITY || capacity > MAX_CAPACITY) {
            throw new IllegalArgumentException("Capacity must be in range (1.." + MAX_CAPACITY + ").");
        }
        int arraySize = 1 + (int) ((capacity - 1) >> 5);
        this.intArray = new int(arraySize);
        this.capacity = capacity;
    }

    private void checkBounds(long bitIndex) {
        if (bitIndex < 0 || bitIndex >= capacity) {
            throw new IllegalArgumentException("Bit index must be in range (0.." + (capacity - 1) + ").");
        }
    }

    @Override
    public void setBit(long bitIndex) {
        checkBounds(bitIndex);
        int index = (int) (bitIndex >> 5);
        int bit = 1 << (bitIndex & 31);
        if ((intArray(index) & bit) == 0) {
            cardinality++;
            intArray(index) |= bit;
        }
    }

    @Override
    public boolean getBit(long bitIndex) {
        checkBounds(bitIndex);
        int index = (int) (bitIndex >> 5);
        int bit = 1 << (bitIndex & 31);
        return (intArray(index) & bit) != 0;
    }

    @Override
    public long getCapacity() {
        return capacity;
    }

    @Override
    public long getCardinality() {
        return cardinality;
    }
}

UniqueStringCounter

This class implements the counter of unique lines in the input Iterable<String> sequence. The counter uses BitVector
implementation. To work, it is required that the input sequence has a final number of possible string-values and this
amount did not exceed the maximum capacity of the bit vector used.

It also requires a hash function that puts a String and a long in an unambiguous match.

package chptr.one;

import javax.validation.constraints.NotNull;
import java.util.Objects;
import java.util.function.ToLongFunction;

public class UniqueStringCounter {

    private final Iterable<String> lines;
    private final ToLongFunction<String> hashFunction;
    private final BitVector bitVector;
    private long linesProcessed;

    public UniqueStringCounter(@NotNull Iterable<String> lines,
                               long capacity,
                               @NotNull ToLongFunction<String> hashFunction) {

        Objects.requireNonNull(lines);
        Objects.requireNonNull(hashFunction);
        this.lines = lines;
        this.hashFunction = hashFunction;
        this.bitVector = new FixedSizeBitVector(capacity);
    }

    public long count() {
        for (String line : lines) {
            long value = hashFunction.applyAsLong(line);
            bitVector.setBit(value);
            linesProcessed++;
        }
        return bitVector.getCardinality();
    }

    public long getLinesProcessed() {
        return linesProcessed;
    }
}

IpStringHashFunction

Hash function to convert a String to a long value. This function must generate a unique value for each unique line,
the collisions are not allowed.

I tested several options for the conversion of IP-String in the long-value and came to the conclusion that they all work around at the same speed that the InetAddress. I do not see the reasons to write my own implementation when the speed of the library function is completely satisfied.

The processing of exceptions really is not needed here, because according to the terms of the task, I am guaranteed that there will be only valid IP. I had to make this processing since otherwise I can’t use this function as a parameter for UniqueStringCounter.

package chptr.one;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.function.ToLongFunction;

public class IpStringHashFunction implements ToLongFunction<String> {

    @Override
    public long applyAsLong(String value) {
        long result = 0;
        try {
            for (byte b : InetAddress.getByName(value).getAddress())
                result = (result << 8) | (b & 255);
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }
        return result;
    }
}

BufferedReaderIterable

A simple adapter that allows you to work with BufferedReader as with Iterable. I could not come up with a better way
to send the contents of the file in UniqueStringCounter, which expects to the Iterable<String> as parameter.

package chptr.one;

import javax.validation.constraints.NotNull;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Iterator;
import java.util.Objects;

public class BufferedReaderIterable implements Iterable<String> {

    private final Iterator<String> iterator;

    public BufferedReaderIterable(@NotNull BufferedReader bufferedReader) {
        Objects.requireNonNull(bufferedReader);
        iterator = new BufferedReaderIterator(bufferedReader);
    }

    public Iterator<String> iterator() {
        return iterator;
    }

    private static class BufferedReaderIterator implements Iterator<String> {

        private final BufferedReader bufferedReader;

        private BufferedReaderIterator(BufferedReader bufferedReader) {
            this.bufferedReader = bufferedReader;
        }

        @Override
        public boolean hasNext() {
            try {
                return bufferedReader.ready();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public String next() {
            String line;
            try {
                line = bufferedReader.readLine();
                if (line == null) {
                    try {
                        bufferedReader.close();
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }
    }
}

IpCounterApp

The main class of the application. Accepts the file name in the -file parameter.

package chptr.one;

import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;

public class IpCounterApp {

    private static String parseFileName(String() args) {
        Objects.requireNonNull(args, "No arguments found. Use -file file-name to processing file.");
        if (args.length == 2 || "-file".equals(args(0))) {
            return args(1);
        }
        return null;
    }

    public static void main(String() args) {
        String fileName = parseFileName(args);
        if (fileName == null) {
            System.err.println("Wrong arguments. Use -file file-name to processing file.");
            return;
        }

        Path filePath = Paths.get(fileName);
        if (!Files.exists(filePath)) {
            System.err.printf("File %s does not exists.n", filePath);
            return;
        }

        try {
            System.out.printf("Processing file: %sn", filePath);
            long startTime = System.nanoTime();
            BufferedReader bufferedReader = Files.newBufferedReader(filePath);
            Iterable<String> strings = new BufferedReaderIterable(bufferedReader);
            UniqueStringCounter counter = new UniqueStringCounter(strings, 1L << 32, new IpStringHashFunction());
            long numberOfUniqueIp = counter.count();
            long linesProcessed = counter.getLinesProcessed();
            long elapsedTime = System.nanoTime() - startTime;
            System.out.printf("Unique IP addresses: %d in total %d.n", numberOfUniqueIp, linesProcessed);
            System.out.printf("Total time: %d milliseconds.n", elapsedTime / 1_000_000);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Why do I ask the new Review?

In previous question
I received a few excellent answers and one excellent bug report. I tried to take into account so many comments as I
could. I also tried to reconsider my approach to the design of classes. I am interested in mostly three questions:

  • How are my new classes are suitable for re-use and extension? What other abstractions can be allocated here and should
    it be done?
  • What should I do with error processing? I know that now it is bad. I just try to fall as early as possible.
  • And most importantly. Do I move in the right direction? I am a newbie in programming and get an overview for my code is
    the only way to learn how to write a quality and understandable code.

sharepoint online – Navigation link in CSV file for termstore

If you want to directly make the terms of the term set in .csv file become navigation links after importing, I think it is impossible.

You have to import the .csv file to term store firstly and then take turns to set the navigation link for each term set here.
enter image description here

virus – Could just downloading (not opening) .tgz file infect Windows 10?

Today I received some e-mail to Thunderbird. It had image attached that I clicked:

enter image description here

Which sent me to onedrive.live.com/download?… and automatically downloaded .tgz file. I am not even sure if the file was really .tgz or it was fake extension. I didn’t open the file, but Windows still made some preview inside download folder:

enter image description here

Is there risk that my laptop is infected even if I didn’t open the file and I just deleted it? Could I get infected because Windows made automatic preview without opening the file?

exploit – VirtualBox: Making a Keylogger file from Kali VM after exploiting Metasploitable (Bridged Adapter)

I am fairly new to Kali Linux and Metasploitable and I am trying to set a Key Logger for when i gain root access to Metasploitable from Kali Linux. I have gained root access by using the use exploit/unix/irc/unreal_ircd_3281_backdoor (I followed everything from here and have successfully penetrated Metasploitable. However, I am using a Bridged Adapter network to make this work and I would like to use a Keylogger that is already downloaded into Kali Linux rather than use wget as I have no access to the internet from Kali Linux.

I am following off this tutorial and he has made the code into a Drop Box link, however i would like to use the downloaded file that is already on Kali Linux.

If there is a easier way to do a Key Logger from Kali VM after exploiting Metasploit, please do not be afraid to suggest it. Thank you

arquivo – recover an image or file for editing

I have a form that has a field to register an image. When loading the editing form, I cannot insert the path of the image that had already been registered. How to insert the path of this image that is retrieved from the bank?

Reduce H5 file to implement it on raspberry 3

I’m trying to reduce the size of the vgg_face_weights.h5 to implement it on my raspberry pi3 board.
when I tried to load the model on the board, it gets killed and the allocation exceeds 10% of the free memory, so i want to know how to reduce the pre-trained model vggface_weights(https://drive.google.com/file/d/1CPSeum3HpopfomUEK1gybeuIVoeJT_Eo/view)
If there’s any kind of suggestion to make this work on the board please let me know
Thanks