Neon Flash
Neon Flash

Reputation: 3233

Echo Code into a File using VBScript

I am writing a VBScript which I want to use to echo the code of another VBScript into an output file.

However, I am unable to write some of the characters to the output file using this method.

If I use the command line method:

cmd.exe /c "@echo "hello"">output.vbs

This works and the string: "hello" is written to the output file.

However, when I do the same using a VBScript, it does not work.

Set objShell = CreateObject("Wscript.Shell")
objShell.Run "%comspec% /c ""@echo ""hello"">output.vbs"

So, is there a way I can echo it into another file retaining the double quotes?

Thanks.

Upvotes: 2

Views: 573

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200503

Your quoting is wrong.

Change this:

objShell.Run "%comspec% /c ""@echo ""hello"">output.vbs"

into this:

objShell.Run "%comspec% /c @echo ""hello"">output.vbs"

Upvotes: 1

Related Questions