免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3473 | 回复: 1
打印 上一主题 下一主题

system()如何调用windows 服务? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-09-06 15:33 |只看该作者 |倒序浏览
我要在脚本中启动mssql2000 服务,

在命令:
sc start  mssql


system($ENV{'SystemRoot'}/sc.exe  start  mssql)  可以吗


请大家帮忙

论坛徽章:
0
2 [报告]
发表于 2006-09-06 16:48 |只看该作者
原帖由 nmxdf 于 2006-9-6 15:33 发表
我要在脚本中启动mssql2000 服务,
在命令:
sc start  mssql

system($ENV{'SystemRoot'}/sc.exe  start  mssql)  可以吗


Hi,
yes. you can do that with system(PROGRAMM, LIST).
TIPS:
If sc.exe is includeed in executable path, you can ommit the absolute path,
otherwise you must add ABSOLUT_PATH_TO/sc.exe.
The arguments or parameter "start" "mssql" should be placed in LIST.
For example:
open a hosts file with notepad:
perl -e "system(notepad,  'C:\WINNT\system32\drivers\etc\hosts');"

To better control of windows services, you can use CPAN module Win32::Service.
pls ref. to the docs.
For example to get all services from given host:

  1. use strict;
  2. use Data::Dumper;
  3. use Win32::Service;

  4. my $host = "YOUR_HOSTNAME";
  5. my $href = {};
  6. my $ws = Win32::Service::GetServices($host, $href);

  7. # dumper all services name
  8. print Dumper($href);
复制代码


regards, ulmer
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP