例如变量名称是:strcmd,变量的值要求是'notepad.exe',不是"'notepad.exe'"如何实现呢?看了许多帮助找不到,郁闷中阿,清大虾知道,谢谢
[ Last edited by bapala on 2006-11-9 at 08:21 AM ]
[ Last edited by bapala on 2006-11-9 at 08:21 AM ]
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
@echo off
set "strcmd='notepad.exe'"
echo %strcmd%
pause
Originally posted by electronixtar at 2006-11-8 07:04:
strcmd='notepad.exe'
没看懂楼主的意思。瞎写一个
Originally posted by bapala at 2006-11-9 04:23:
老闆的意思是定期的殺掉一個進程,例如notepad.exe,由於老闆還沒有確定名字,所以我這裡要用strcmd代替進程的名稱,所以希望strcmd的值是'notepad.exe'@...
strCmd = Chr(39) & "notepad.exe" & chr(39)
strProcess = "notepad.exe"
for each x in getobject("winmgmts:win32_process").instances_
if ucase(x.name) = ucase(strProcess) then x.Terminate
next
strProcess = "notepad.exe"
for each x in getobject("winmgmts:").instancesof("win32_process")
if ucase(x.name) = ucase(strProcess) then x.Terminate
next
Originally posted by 3742668 at 2006-11-9 08:06:
Re bapala:
如楼上几位所说,用引号包起来的'是不会被当做注释的。
另外,如果碰上觉得难处理的字符可以尝试用chr函数来替代。例如:
strCmd = ...
我是在sql語句中用的,所以要用'notepad.exe' ,不可用"'notepad.exe'" or chr() & "notepad.exe" & chr(),版主給的另兩種方法倒是可行的.
也謝謝上面的各位兄弟了!