Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i wanna write this to a bat file

@echo off

echo "lol"

i have the script for writing to the file here:

Dim FILE_NAME As String = "C:\Users\Game-pc\AppData\Roaming\filetest\test.bat"
Dim i As Integer
Dim aryText(4) As String

aryText(0) = "@echo off"
aryText(1) = "echo lol"

Dim objWriter As New System.IO.StreamWriter(FILE_NAME)

For i = 0 To 4

objWriter.WriteLine(aryText(i))

Next

objWriter.Close()


the problem is i cant write echo "lol" becous of the " char how do i make the script ingore this?

What I have tried:

searching on google but i did not find anything.
Posted
Updated 7-Dec-16 2:34am
Comments
[no name] 7-Dec-16 8:36am    
If you want to write "lol" to your batch file, you will probably need to escape the " when writing the string.

1 solution

Write the double quotes as well:
VB
aryText(1) = "echo ""lol"""
will do it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900