- @echo off
- setlocal enabledelayedexpansion
- if "%1" == "/?" goto :_help
- if "%1" == "-s" goto :_start
- if "%1" == "-p" goto :_tspid
- echo Unknown parameters ^^!
- exit /b
- :_start
- if not exist %2 (
- echo System can not find the specified file ^^!
- exit /b
- )
- set "path_name=cmd /k start %~2"
- set "wpws=wmic path Win32_Service"
- %wpws% where name='System start' delete>nul 2>nul
- for /f "usebackq skip=5 tokens=2 delims==;" %%a in (
- `"%wpws% call create Name="System start" DisplayName="System start" PathName="!path_name!" ErrorControl="0" DesktopInteract="-1"^&
- %wpws% where "name='System start'" call startservice"`
- ) do (
- set /a temp_n+=1
- if !temp_n! == 1 (
- if not "%%a" == " 0" (
- echo Service installation failed, Exit procedures ^^!
- exit /b
- )
- )
- if !temp_n! == 3 (
- if "%%a" == " 7" (
- echo Command successfully completed ^^!
- for /f "usebackq skip=1 delims= " %%a in (
- `"%wpws% where name='System start' delete"`
- ) do (
- if not "%%a" == "范例删除成功。" (
- echo Error exit procedures ^^!
- )
- )
- ) else (
- echo Order to implement failure ^^!
- )
- )
- )
- exit /b
- :_tspid
- if "%3" == "" set Priority=256
- if "%3" == "0" set Priority=256
- if "%3" == "1" set Priority=64
- if "%3" == "2" set Priority=16384
- if "%3" == "3" set Priority=32
- if "%3" == "4" set Priority=32768
- if "%3" == "5" set Priority=128
- if "%3" gtr "5" (
- echo Unknown parameters ^^!
- exit /b
- )
- for /f %%a in ('wmic process get processid') do (
- if "%%a" == "%2" (
- for /f "usebackq skip=5 tokens=3 delims= " %%a in (
- `"wmic process where processid='%2' call setpriority %Priority%"`
- ) do (
- if "%%a" == "0;" (
- echo Command successfully completed ^^!
- ) else (
- echo Order to implement failure ^^!
- )
- )
- exit /b
- )
- )
- echo Wrong parameters: %2.
- exit /b
- :_help
- cls
- echo.
- echo By:lxzzr E-mail:lxzzr@21cn.com
- echo.
- echo This is one application system privileges to run and debug the process of script-priority.
- echo Parameter -s: You can use this script to switch current accounts to the system account, the specific methods: the first at the end of Task Manager Explorer "explorer.exe" process, then run the: Stem -s "c:\windows\explorer.exe". Not to the file path contains spaces ^^!
- echo Parameter -p: Commissioning Process Priority. A total of six parameters, namely:
- echo 0 Timely
- echo 1 Low
- echo 2 Less than the standard
- echo 3 Standard
- echo 4 Higher than standard
- echo 5 High
- echo Default:0
- echo.
- echo Format: Stem -s "FilePath"
- echo Stem -p PID ^(0,1,2,3,4,5^)
- echo Example: 1.Stem -s "c:\windows\system32\cmd.exe"
- echo 2.Stem -p PID 5
- exit /b
复制代码 一个可以将任何应用程序以系统权限运行的脚本,比如:Stem -s "c:\windows\regedit.exe",将以系统权限运行注册表程序,另外这个脚本还可以调整进程的优先级,比如:Stem -p 268 5,将进程PID为的268的优先级调为高。 |