Using & with echo?

January 8, 2011 at 02:54:34
Specs: Windows 7
Hello, i'm trying to create a batch file that writes a VBS file with 3 lines which are:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "%windir%\Super.BAT" & Chr(34), 0
Set WshShell = Nothing

I'm using echo * > super.vbs, but the second line contains 2 &'s and it echo's the part before the first & and then says 'Chr(34) is not a valid command' and the resulting vbs file looks like this:

Set WshShell = CreateObject("WScript.Shell")
Set LINE3=Set WshShell = Nothing

Is there any way to echo the second line into the vbs file? or to have the same effect of the vbs file but in a format that can be echoed from a batch file?

here is the problem segment i'm using:

@echo off
Echo Set WshShell = CreateObject("WScript.Shell") > Super.vbs
Echo WshShell.Run chr(34) & "%windir%\Super.BAT" & Chr(34), 0 >> Super.vbs
Echo Set LINE3=Set WshShell = Nothing >> Super.vbs

See More: Using & with echo?

Report •

January 8, 2011 at 02:57:46
The general escape character is "^", but percentage signs need to be doubled.

echo %% ^& ^| ^< ^> ^^ ^)

Report •

January 8, 2011 at 03:02:51
thanks so much! apparently easy fix that i couldnt figure out
easy for you

Report •

Related Solutions

Ask Question