wk198 发表于 2008-8-31 17:43:49

au3 “” 号的使用 问题

一个变量 如果被 加上了 双引号 只是被视为普通字符
但有时候 需要 加 双引号 怎么转换
比如 $abc =本地连接 2
RunWait(@ComSpec & ' /c netsh interface set interface "$abc" disabled', "", @SW_HIDE)

是错误的应该是
RunWait(@ComSpec & ' /c netsh interface set interface "本地连接 2" disabled', "", @SW_HIDE)

本地连接 2 是不确定的 每台机子有可能不通
必须变量获取
但 netsh interface set interface "本地连接 2" disabled   中 本地连接 2 又必须加 “”
如何转换

KiwiCsj 发表于 2008-8-31 17:51:23

你的例子中,以单引号为代码与字符串的边界,那么你想要在字符串中出现的双引号应当写在单引号的字符串这边,这样就使该双引号成为一个对au3脚本而言的字符串,而不是代码的一部分。

wk198 发表于 2008-8-31 17:55:14

太感谢楼上的
好简单 我怎么没想到呢
太笨了
老想着 VB 里面的转换去了
3Q

ken0137 发表于 2008-9-1 22:01:25

RunWait(@ComSpec & ' /c netsh interface set interface "'&$bianliang&'" disabled', "", @SW_HIDE)

redapple2008 发表于 2008-9-1 22:14:19

RunWait(@ComSpec & ' /c netsh interface set interface '&chr(34)&"本地连接"&chr(34)&' disabled', "", @SW_HIDE)
页: [1]
查看完整版本: au3 “” 号的使用 问题