Hello!This time, as one of the countermeasures for the case where restart is required during processing, I tried to summarize how to make a batch that is automatically executed after restart.
There are a lot of processes that require a reboot
There are many opportunities to use batches when installing modules, such as initial Windows setup and customization, and vulnerabilities.
In some cases, you will be required to reboot when you actually apply the software, drivers, Windows updates, etc.So let's create a batch that will work even in situations where a reboot is required.
Use the RunOnce registry
If you simply want it to run after a reboot, using the RunOnce registry will suffice.
This time, we will use HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ Windows \\ CurrentVersion \\ RunOnce on the assumption that the user will execute it after logging on.
For the RunOne registryherePlease refer to.
Reboot judgment using arguments
You can add arguments to the RunOnce registry when registering the script.
By giving the label you want to jump to, you can move to the required processing after restarting.
The first argument of the batch is stored in% 1. (The second argument is% 2, the third argument is% 2 ...
Then write the decision at the very beginning of the batch.
This allows the process to be executed step by step in one batch.
It's convenient for distribution.
if "% 1" neq "" goto:% 1
It should be like this.
* It did not work unless there were "" "at both ends of% 1 in the conditional expression of IF.
Now, here is the code compiled based on the above.
Please rewrite the process according to the content.
- The RunOnce registry is useful for running after a reboot
- You can complete the process by yourself by using% ~ 0 and the argument
It is a technique that can be used for various automated processes, so please take advantage of it.
I hope it helps you.