0
WshShell.Run """C:\Program Files\Target.exe"" -s"

In command above, I want to use a string instead of the path, but it is not working!

Directory = "C:\Program Files\Target.exe"
WshShell.Run """Directory"" -s"

How to do it?

Inside Man
  • 4,194
  • 12
  • 59
  • 119

1 Answers1

1

Using Chr(34) might make things clearer.

Directory = "C:\Program Files\Target.exe"
WshShell.Run Chr(34) & Directory & Chr(34) & " -s"

Otherwise, the syntax you're looking for gets a bit complicated:

WshShell.Run """" & Directory & """ -s"

If you need to use a quote character within a string literal, it must be doubled. And if you need to include a VBScript variable, it should be concatenated (&).

Bond
  • 16,071
  • 6
  • 30
  • 53