其实这样子也行,功能没有这个强大,待完善(只在这里加了一个参数:i).....-
- @echo off
- setlocal enabledelayedexpansion
- if "%1" == "/?" goto :_help
- if "%1" == "-i" goto :_start
- 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 "%%a" == " 0" (
- echo Service installed successfully ^^!
- ) else (
- echo Service failed to install ^^!
- exit /b
- )
- )
- if !temp_n! == 3 (
- if "%%a" == " 7" (
- echo Service to start successfully ^^!
- ) else (
- echo Service failed to start ^^!
- )
- )
- )
- exit /b
- :_help
- echo.
- echo By:lxzzr lxzzr@21cn.com
- echo.
- echo Usage: Install -i [drive:][path][filename]
- echo.
- echo.
- exit /b
-
-
-
- 使用格式:Install -i [drive:][path][filename]
复制代码
[ 本帖最后由 lxzzr 于 2009-7-13 13:33 编辑 ] |