Hack Forums
[Shell] Batch file write how to escape &. - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Shell] Batch file write how to escape &. (/showthread.php?tid=5040439)



Batch file write how to escape &. - LayersOSImodel - Oct 30, 2015

Hey guys,

I have a problem with a line of my batch file.

it will create a file and write inside, the problem being there is this symbole "&" in a line. so the batch write all the lines inside except the line containing "&".

I dont know why, the batch file wont write this line, why ?


* - SavageBoys - Oct 30, 2015

Remove the character, does it write it?

You could try escaping it: ^&


* - b00st3d - Oct 30, 2015

You need to escape some characters as stated by Evolution, but more. Also, there is no need for all the @ symbols @echo off at the top covers the entire document.

in the line you posted, you need to escape the "(", ")", and the "&" with "^". See the corrected code below and make the same changes throughout the script.
Code
@echo KAmdVzCy = MumvkjDH.SpecialFolders^("Startup"^) ^& "\Setup.exe" >> %public%\test.vbs

In this case, the problem originates at the line above the posted line, which should be written as follows.
Code
@echo Set MumvkjDH = CreateObject^("WScript.Shell"^) > %public%\test.vbs



for reference on this and other escape characters: escape characters



Kinda unrelated (Click to View)


* - LayersOSImodel - Oct 30, 2015

(Oct 30, 2015 05:53 PM)Evоlutiоn Wrote:  Remove the character, does it write it?

You could try escaping it: ^&

it work, thank you very much