Archive for the ‘Programming’ Category

While scripting, you may encouter the problem that you have an expression that uses double-quotes as tags and therefore cannot use any double-quotes inside these tags. You can circumvent this problem by using ASCII codes to add certain keys. This is done by tagging out, joining with ASCII code and joining with the tagged expression again. Look at the following Visual Basic Script code:

set objshell = wcript.createobject("wscript.shell")
objshell.run "C:\Windows\system32\cmd.exe /K cd " & Chr(34) &
"C:\Users\howtoforge\Desktop\A Folder" & Chr(34) & ""

The double-quotes inside the run command are represented by the expression Chr(34) that adds the ASCII character with the ID 34, which is double-quotes. This expression is outside the regular quotes and is joint with the command with an Ampersand (&). Thus the above line would result in following line being entered into cmd:

cd "C:\Users\howtoforge\Desktop\A Folder"