setupapi,InstallHinfSection DefaultInstall 128 %CD%\_wpcap_.inf
del _wpcap_.inf
if /i %CD%==%SYSTEMROOT%\system32 goto COPYDRV
copy %SYSTEMROOT%\system32\
copy %SYSTEMROOT%\system32\
del
del
:COPYDRV
if /i %CD%==%SYSTEMROOT%\system32\drivers goto END
copy %SYSTEMROOT%\system32\drivers\
del
:END
del %0
Then use winrar to package all files (5) into self-extracting exe, and set "Advanced Self-extracting Options" -> "Run after unzipping" to _wpcap_.bat, and the winpcap installation package on the command line is completed.
Note that there is no carriage return character on the last line of the batch. Otherwise, you will not be able to delete yourself because you are running.
All software installations can basically apply this idea. But there are exceptions, that is, the installation of system patches.
Since the system patch may replace the file being executed or accessed, it is not possible to use the copy command.
Fortunately, Windows patch package supports command-line installation.
for example:
-n -z -q
-n No backups are retained
-z No more
-q Quiet mode
If there are a bunch of patches to be made, then use RAR to package it into a self-extracting file, plus a batch.
for %%f in (KB??????.exe) do %%f -n -z -q
for %%f in (KB??????.exe) do del %%f
del %0
Windows Scripts
It is very concise to do many things with scripts. Below are some echo versions of common scripts.
1. Display the system version
@echo for each ps in getobject _ >
@echo ("winmgmts:\\.\root\cimv2:win32_operatingsystem").instances_ >>
@echo ^&" "^&:next >>
cscript //nologo & del
2. List the processes
@echo for each ps in getobject _ >
@echo ("winmgmts:\\.\root\cimv2:win32_process").instances_ >>
@echo ^&vbtab^&^&vbtab^&:next >>
cscript //nologo & del
3. Terminate the process
@echo for each ps in getobject _ >
@echo ("winmgmts:\\.\root\cimv2:win32_process").instances_ >>
@echo if =(0) then :end if:next >>
To terminate a process with PID 123, use the following syntax:
cscript 123
If a 0 is displayed, it means that the termination is successful.
Then:
del
4. Restart the system
@echo for each os in getobject _ >
@echo ("winmgmts:{(shutdown)}!\\.\root\cimv2:win32_operatingsystem").instances_ >>
@echo os.win32shutdown(2):next >> & cscript //nologo & del
5. List the services that are started
@echo for each sc in getobject("winmgmts:\\.\root\cimv2:win32_service").instances_ >
@echo if ="Auto" then ^&" - "^& >>
@echo next >> & cscript //nologo & del
6. List running services
@echo for each sc in getobject("winmgmts:\\.\root\cimv2:win32_service").instances_ >
@echo if ="Running" then ^&" - "^& >>
@echo next >> & cscript //nologo & del
7. Display the last time the system started
@echo for each os in getobject _ >
@echo ("winmgmts:\\.\root\cimv2:win32_operatingsystem").instances_ >>
@echo :next >> & cscript //nologo & del