Is there an escaping character (when using double-quotes in string declarations)?

给你一囗甜甜゛ 提交于 2019-12-11 10:28:50

问题


This is the code I'm running:

RunWait("ComSpec & " /c Start 'D:\Program Files (x86)\Pidgin\pidgin.exe'")

I have also tried without semiquotes and with quotes but then I get syntax errors.


回答1:


The problem is that the file path on your computer has spaces in it and needs double-quotations around it.

Try "D:\Program Files (x86)\Pidgin\pidgin.exe" from the command prompt with the double-quotations and make sure the program starts.

Once you know it works you can add it to your AutoIt code like so (notice that it is surrounded by single-quotations).

RunWait(@ComSpec & " /c " & '"D:\Program Files (x86)\Pidgin\pidgin.exe"')



回答2:


In AutoIt, you can escape quotes simply by repeating them (same way it happens on Batch/DOS):

RunWait(@ComSpec & " /c ""Start D:\Program Files (x86)\Pidgin\pidgin.exe""")



回答3:


Really not an expert, but it looks like there is a problem with the amount of quotes in your code

I would try something like this:

(RunWait(@ComSpec & " /c Start" & "D:\Program Files (x86)\Pidgin\pidgin.exe")



回答4:


As per Documentation - FAQ - Double quotes:

If you want to use double-quotes inside a string then you must "double them up". So for every one quote you want you should use two. ...

or use single quotes instead ...

Examples:

RunWait(@ComSpec & " /c " & """D:\Program Files (x86)\Pidgin\pidgin.exe""")
RunWait(@ComSpec & ' /c ' & '"D:\Program Files (x86)\Pidgin\pidgin.exe"')

However, there is no need for the "SPECified secondary COMmand interpreter" (or @ComSpec), nor escaping of double-quotes. Example:

Global Const $g_sFile = "D:\Program Files (x86)\Pidgin\pidgin.exe"

Run($g_sFile, "")

Related.




回答5:


You have an unmatched " in the middle.

Usually / or \ are used for escaping. Try /" or \" because I'm not sure which of both works with AutoIt.



来源:https://stackoverflow.com/questions/33901137/is-there-an-escaping-character-when-using-double-quotes-in-string-declarations

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!