This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / 关于dos命令的问题. 如何把一个命令的输出存储到一个变量(环境变亮)中去,然后根据这个变量的值来做不同的事情?比如
set myvar=echo 111
if myvar ==111
echo 222
上面的代码只是示意代码,不能实际运行
限制:不许使用临时文件,不许用第三方软件,不许自己编写exe,不许使用script语言。
运行环境:xp 或者2000
-interview(intervieweree);
2006-1-14
{203}
(#2718833@0)
-
FYISET myvar=111
IF %myvar%==111 ECHO 222
-bingle(bingle);
2006-1-14
{39}
(#2718874@0)
-
投机取巧。如果那个
echo 111 换乘其他命令, dir | find "mydir" 呢?
-interview(intervieweree);
2006-1-14
(#2718920@0)
-
no one interested in this one?
-interview(intervieweree);
2006-1-15
(#2720277@0)
-
不是no one interested in this,而是这年头懂DOS的人不多了。@echo off
if "%1" == "111" goto 111
goto end
:111
echo 222
:end
-bdbs(不得不说);
2006-1-16
{76}
(#2723008@0)
-
a real situationa dos command untility, every 1 nibute it needs to find whether one specific service is down, and if yes, restart it.
-interview(intervieweree);
2006-1-15
{118}
(#2720284@0)
-
check sc.exe command.run "sc start wzcsvc" every minute, if it is stop, it will restart it, if it is not, it will just skip it.
-redspider(红蜘蛛);
2006-1-15
{108}
(#2720367@0)
-
Thank you. a few questionsBTW, what is the diference between "net start" and "sc start"?
Noticed ~net start~ can do the same job.
But when try to do net start Alerter, it takes a human noticible while to complete.
While using sc start, it's faster. Why?
What is the performance hit when you try to restart the service while it's running?
-interview(intervieweree);
2006-1-15
{328}
(#2720480@0)
-
my answer...sc == service controler
1. net start can start the service locally, sc start can start the service remotely.
2. net start has less option, sc has lots of features then net start.
3. net start comes with windows, sc comes with resource kit (win2000)(xp/2003 coms with windows)
4. i think no performance hit for the service.
for more info, do sc /? or sc config /?
-redspider(红蜘蛛);
2006-1-15
{371}
(#2720798@0)
-
thanks
-interview(intervieweree);
2006-1-15
(#2721590@0)
-
finala property can be set to restart service once it crashes.
-interview(intervieweree);
2006-1-16
{57}
(#2724086@0)
-
sc failure myservice action= restart/5000
-redspider(红蜘蛛);
2006-1-16
(#2724415@0)
-
能不能请教你到底要做什么,也许大家有其他的方法。
-ready4u(就等你了);
2006-1-18
(#2727305@0)