7. 创建Subversion服务之补充

手工启动Subversion服务容易出错,尤其是一个空格没打好也不行。所以我写了两个脚本,一个用来创建服务,一个用来删除服务。这两个脚本在Windows资源管理器里可直接运行。

Notice:就像第一个脚本注释里写的一样,运行Create Service.js时请右键点击“在命令行里运行”方可。不然会产生运行时错误。

Create Service.js

/**/ /*    Author: 杨冬
    Date: 2007-11-24
    
    This script is used to create subversion service and start it. The user is supposed to excute this script in the command line
    mode. Right click on the script file, select "Open in command line". When the script was running, it would ask you to type the
    svnserve.exe path which is exactly the same as subversion installation path and your respository path. If you specify nothing,
    their values would be replaced by their default values which is only suitable on my computer. :) Therefore, DON'T left the
    respository path empty.
*/


//  Declarations
var  serviceName  =   " svn " ;                                                 //  Service name
var  srvPath  =   "" ;                                                     //  Path of svnserve.exe
var  resPath  =   "" ;                                                     //  Path of your svn respository
var  defaultSrvPath  =   " C:\\Program Files\\Subversion\\bin\\svnserve.exe " ;     //  Default binPath
var  defaultResPath  =   " C:\\Documents and Settings\\杨冬\\Files\\SvnRepos " ;     //  Default resPath
var  displayName  =   " Subversion Server " ;     //  Display name

//  Read the srvPath and resPath from user.
var  stdin  =  WScript.Stdin;
var  stdout  =  WScript.Stdout;
var  srvPathPrompt  =   " 请输入 svnserve.exe 的安装目录: " ;
stdout.WriteLine(srvPathPrompt);
var  srvPath  =  stdin.ReadLine();
var  resPathPrompt  =   " 请输入您 Repository 的目录: " ;
stdout.WriteLine(resPathPrompt);
var  resPath  =  stdin.ReadLine();
//  If user entered nothing, then set srvPath and resPath to their default values.
if  (srvPath  ==   "" ) srvPath  =  defaultSrvPath;
if  (resPath  ==   "" ) resPath  =  defaultResPath;

//  Assemble command string
var  cmdStr  =   " sc create  "   +  serviceName  +   "  binpath= \ " \\\ ""   +  srvPath  +   " \\\ ""  +
    
"   -- service  - "  +  " \\\ ""   +  resPath  +   " \\\ " \ "  displayname= \ ""  + displayName +
    
" \ "  depend= Tcpip start= auto " ;

//  Create the svn service.
var  wshShell  =  WScript.CreateObject( " WScript.Shell " );  //  Get WshShell object.
var  oExec  =  wshShell.Exec(cmdStr);  //  Execute command.
while  (oExec.Status  ==   0 ) WScript.Sleep( 100 );  //  Wait for command execution finish.

//  Start the svn service.
var  runCmd  =   " net start  "   +  serviceName;
oExec 
=  wshShell.Exec(runCmd);
while  (oExec.Status  ==   0 ) WScript.Sleep( 100 );

//  Show the user tip.
var  tipStr  =   " 服务已经启动\n "   +
    
" svnserve.exe 路径:\t "   +  srvPath  +   " \n "   +
    
" respository 路径:\t "   +  resPath;
wshShell.Popup(tipStr);

Delete Service.js
/**/ /*    Author: 杨冬
    Date: 2007-11-24
    
    This script will delete the subversion service on your computer. But the service must be named as "svn".
    If not, there would be no effect at all.
*/


var  serviceName  =   " svn " ;     //  Service name
var  stopCmd  =   " net stop  "   +  serviceName;
var  delCmd  =   " sc delete  "   +  serviceName;

//  Execute command
var  wshShell  =  WScript.CreateObject( " WScript.Shell " );  //  Get WshShell object.
var  oExec  =  wshShell.Exec(stopCmd);  //  Stop the service
while  (oExec.Status  ==   0 ) WScript.Sleep( 100 );  //  Wait for command execution finish.
var  oExec  =  wshShell.Exec(delCmd);  //  Delete the service
while  (oExec.Status  ==   0 ) WScript.Sleep( 100 );  //  Wait for command execution finish.

//  Show user tip.
var  tipStr  =   " 服务已经删除 " ;
wshShell.Popup(tipStr);

转载于:https://www.cnblogs.com/ydong/archive/2007/11/25/971558.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值