Robert
Robert

Reputation: 135

Writing out a quoted variable

I"m struggling with some code that writes out a VBS file, for a particular line that writes a file path which holds a variable. Struggling with getting the double-quotes right and placing variable correctly.

This line currently works, but only if "C:\tmp" dir is already created:

Print #PayLoadFile, "HTTPDownload ""http://host.example.net/test1.exe"", ""C:\tmp"" "

Instead of C:\tmp, I would like to write to user profile directory. But I can't get the part to write out correctly in VBS file. I'm trying this:

Print #PayLoadFile, "HTTPDownload ""http://host.example.net/test1.exe"", ""Replace(myFile)"" "

The 'myFile' variable holds a string of the user profile directory ("c:\Users\John Doe")

It should print out to the vbs file as:
HTTPDownload "http://host.example.net/test1.exe", "C:\Users\John Doe"

But instead it looks like this: HTTPDownload "http://host.example.net/test1.exe", "Replace(myFile)"

Upvotes: 1

Views: 60

Answers (1)

YowE3K
YowE3K

Reputation: 23974

You need to concatenate the value of myFile into the string:

Print #PayLoadFile, "HTTPDownload ""http://host.example.net/test1.exe"", """ & myFile & """"

Upvotes: 1

Related Questions