


Use bat batch file to operate windows example code
A bat batch file that implements starting the windows process and delaying the shutdown. It is used to open and close IE. Friends who learn batch processing can refer to it.
A few days ago, the leader asked us to vote on the website to improve his ranking, but each person's vote only amounted to more than 100 votes. A few days later, my boss asked me if I would create a vote-swiping program to improve my ranking. I said I could give it a try. After researching for a day, I finally made it. I was so excited that I couldn't sleep all night. Now take it out and share it.
To put it bluntly, what I made is actually a batch file. The batch extension is .bat. In fact, the voting page only uses session to control whether to vote. As we all know, the session variable will automatically disappear after IE is closed and reopened. A new connection will be created when the page is opened, so you can vote again. This page uses AJAX. I found the JS where ajax is located, found out its real voting page, and passed the ID through the page to implement voting. What we need to do now is to automatically open the IE connection voting page, then automatically disconnect and automatically reconnect, thereby achieving repeated voting.
This voting website has two fatal points. One is that voting is not controlled by IP but is controlled by the session server, which results in repeated voting with one IP. Second, the parameters of the actual voting processing page are transmitted through GET. This This will lead to the possibility of cheating.
By exploiting the above two vulnerabilities, I also made a bat batch process, as follows:
The code is as follows:
@ echo off echo 正在关闭冗余进程,请稍等...... taskkill /f /im iexplore.exe echo -------------程序初始化完毕,请指示!---------- echo. & pause :openie echo 正在投票,请稍等...... start "" "C:\Program File s\Internet Explorer\iexplore.exe" echo IE打开完成! ping 127.0.0.1 -n 2 taskkill /f /im iexplore.exe echo 延时2秒关闭投票完成! goto openie echo. & pause
Explanation of key points:
taskkill /f /im iexplore .exe forcibly closes the IE process. Of course, it can also close other processes. The process name can be found through the task manager.
start "" "C:\Program Files\Internet Explorer\iexplore.exe" This is to open a windows program, pay attention to the path, and be sure not to lose the "" after start.
ping 127.0.0.1 -n 2 Use this to delay. Everyone knows that delayed execution of bat batch processing is too troublesome. This is simpler. It should be noted that you must ping the local 127.0.0.1, otherwise It may lead to different timing lengths. -n 2 means repeating twice, which is about 2 seconds. Of course, the duration is adjustable, just adjust the number.
Key point: infinite loop of bat batch processing. :openie means to set a point. This can be arbitrary. Any combination of letters will do. Do not repeat keywords. goto openie means to return to the point openie set previously. The set return points must correspond to each other.
Now you can copy the above code into a text document. Be sure to change the extension to .bat. .bat is the standard extension for batch processing. Of course, a very classic program of 98 is autoexec.bat. I believe many people who have come here have heard of it. If you are interested, you can search it on Baidu. Of course, you can also start or end the processes of other programs by analogy.
If you have any questions, you can ask me. The QQ number is on the right side at the bottom of the page. Let’s improve together and make progress together. Haha
The following program was found online. You can copy it to know exactly what it does. In some places, I don’t understand. If you have high comprehension ability, study it yourself!
Tips: The following program monitors whether a process exists. If it does not exist, it will start. If the process is lost, it will also start, which means the program will run forever!
The code is as follows:
@echo off set _task=notepad.exe set _svr=c:\windows\notepad.exe set _des=start.bat :checkstart for /f "tokens=5" %%n in ('qprocess.exe ^| find "%_task%" ') do ( if %%n==%_task% (goto checkag) else goto startsvr ) :startsvr echo % time % echo ********程序开始启动******** echo 程序重新启动于 %time% ,请检查系统日志 >> restart_service.txt echo start %_svr% > %_des% echo exit >> %_des% start %_des% set/p=.<nul for /L %%i in (1 1 10) do set /p a=.<nul&ping.exe /n 2 127.0.0.1>nul echo . echo Wscript.Sleep WScript.Arguments(0) >%tmp%\delay.vbs cscript //b //nologo %tmp%\delay.vbs 10000 del %_des% /Q echo ********程序启动完成******** goto checkstart :checkag echo %time% 程序运行正常,10秒后继续检查.. echo Wscript.Sleep WScript.Arguments(0) >%tmp%\delay.vbs cscript //b //nologo %tmp%\delay.vbs 10000 goto checkstart
[Related recommendations]
1. Steps to build a Java development environment under Windows 7 (illustration)
2. Install Ulipad editor under Windows system
3. Use Python to develop windows desktop programs
4. Teach you how to install python2 and python3 versions in Windows environment
The above is the detailed content of Use bat batch file to operate windows example code. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Solving the problem of slow Photoshop startup requires a multi-pronged approach, including: upgrading hardware (memory, solid-state drive, CPU); uninstalling outdated or incompatible plug-ins; cleaning up system garbage and excessive background programs regularly; closing irrelevant programs with caution; avoiding opening a large number of files during startup.

How to implement Windows-like in front-end development...

Pull vertical guides in Photoshop: Enable ruler view (View > ruler). Hover the mouse over the vertical edge of the ruler, and then the cursor becomes a vertical line with double arrows and hold and drag the mouse to pull out the reference line. Click Delete by dragging the guide, or hovering it into a cross.

The MySQL connection may be due to the following reasons: MySQL service is not started, the firewall intercepts the connection, the port number is incorrect, the user name or password is incorrect, the listening address in my.cnf is improperly configured, etc. The troubleshooting steps include: 1. Check whether the MySQL service is running; 2. Adjust the firewall settings to allow MySQL to listen to port 3306; 3. Confirm that the port number is consistent with the actual port number; 4. Check whether the user name and password are correct; 5. Make sure the bind-address settings in my.cnf are correct.

Unable to access MySQL from the terminal may be due to: MySQL service not running; connection command error; insufficient permissions; firewall blocks connection; MySQL configuration file error.

The solution to MySQL installation error is: 1. Carefully check the system environment to ensure that the MySQL dependency library requirements are met. Different operating systems and version requirements are different; 2. Carefully read the error message and take corresponding measures according to prompts (such as missing library files or insufficient permissions), such as installing dependencies or using sudo commands; 3. If necessary, try to install the source code and carefully check the compilation log, but this requires a certain amount of Linux knowledge and experience. The key to ultimately solving the problem is to carefully check the system environment and error information, and refer to the official documents.

The main reasons for MySQL installation failure are: 1. Permission issues, you need to run as an administrator or use the sudo command; 2. Dependencies are missing, and you need to install relevant development packages; 3. Port conflicts, you need to close the program that occupies port 3306 or modify the configuration file; 4. The installation package is corrupt, you need to download and verify the integrity; 5. The environment variable is incorrectly configured, and the environment variables must be correctly configured according to the operating system. Solve these problems and carefully check each step to successfully install MySQL.
