Self defined vbs script to realize the method of delaying the start of specified program after startup

Time:2022-1-6

summary

When the system is turned on, many drivers are automatically started, which makes the mouse dull for a long time after the computer is turned on. In order to speed up the start-up speed of windows, after referring to many data on the Internet, this paper sorted out the method of using vbs script to realize the delayed start-up program after start-up

VBS content example:

Copy codeThe code is as follows:

Dim delayer
Set delayer = CreateObject(“WScript.Shell”)
WScript.sleep 8000
delayer.Run “””C:\Program Files(x86)\Kingsoft\Klive\Klive.exe”””, 0, FALSE
Set delayer = Nothing
WScript.quit

 

VBS example statement analysis

The #1#2#5#6 statement does some variable declaration, initialization and aftermath work.
#3 statement: “wscript.sleep 8000”; Where 8000 marks the delay time, in milliseconds, 8000 represents the delay of 8 seconds;
#4 statement: delay Run”””C:\Program Files (x86)\Kingsoft\Klive\Klive.exe”””,0, FALSE;
The key to this statement is that the run function [3] has three parameters:
The first parameter: is the location of the startup program. Special attention: if there is a space in the location, you need to use three double quotes as above.
The second parameter: the available values are 11 numbers from 0 to 10. The meaning of each number is as follows:
0 hides one window and activates another.
1 activate and display the window. If the window is minimized or maximized, the system restores it to its original size and location. The first time the window is displayed, the application should specify this flag.
2 activate the window and display it as a minimized window.
3 activate the window and display it as a maximized window.
4 display windows according to the nearest window size and position. The active window remains active.
5 activate the window and display it at its current size and position.
6 minimize the specified window and activate the next top window in Z order.
7 displays the window as a minimized window. The active window remains active.
8 displays the window in its current state. The active window remains active.
9 activate and display the window. If the window is minimized or maximized, the system restores it to its original size and location. The application should specify this flag when restoring minimized windows.
10 set the display state according to the program state of the startup application.
The third parameter indicates whether the script will wait or continue to execute. If it is set to true, the script will wait for the called program to exit and then execute backward. If false, execute the next statement without waiting for the program to return.

Custom vbs script

Through the above example analysis [2], I believe I should understand the writing method of vbs script!
In fact, it’s very simple. You just need to copy the examples and add custom sleep time and run program statements in the middle.
By the way, remind netizens with weak computer knowledge that they can press Win + R, and then enter the msconfig command in the box. In the “startup” option box, check which programs are started, cancel the check box, and then write the corresponding program name and location into the vbs script for delayed startup.
After writing the vbs script file, put it in the “startup” folder and let its vbs script start and run. Quickly experience the fast boot, very cool!!!

Some problems and Solutions

However, in this process, I personally encountered a problem: the anti-virus software on my computer is Jinshan drug bully. If I use the above method to start Jinshan drug bully, the main interface of Jinshan drug bully will still pop up when I start Jinshan drug bully. I’m a little upset (forgive me) I just hope Jinshan drug bully can stay quietly in the system tray after starting up.

What shall I do?

It happened that when I used msconfig to check the startup item of Jinshan drug bully, I found that the command it started was not only the program location, but also a parameter – autorun. I immediately understood that the original Jinshan drug bully’s running program uses the – autorun parameter to realize that the main interface does not appear during startup, but only palletization.

However, the run function cannot pass parameters to the started program. What about this?

At this time, I thought of “shortcut”. When you create a shortcut for an EXE file, right-click – properties. In the pop-up property box, there is an item “target” in the “shortcut” tab, which corresponds to the location of the target file. You can pass parameters here in time.

Take my Jinshan drug bully as an example. Its target location is “D: \ program files (x86) \ Kingsoft \ Kingsoft antivirus \ kxetray. Exe”,
The corresponding value in the target item in the shortcut attribute is “D: \ program files (x86) \ Kingsoft \ Kingsoft antivirus \ kxetray. Exe”.
Pass the parameter to it and change the target item to: “D: \ program files (x86) \ Kingsoft \ Kingsoft antivirus \ kxetray. Exe” – autorun.
Then change the first parameter of the run function in VBS to the location of the shortcut, so that the parameters can be passed indirectly.