Page 1 of 1

Saving input from batch into text file [Partially complete]

Posted: 06 Feb 2010 02:03
by bre
Hi,
i would like to save some data into a text file, so far i have.

@cls
@:COMPUTERNAME
@set /p ComputerN=What is the Computer Name?
@set /p yn=Are you sure [y/n]?
@if "%yn%"=="" (echo Not entry) & (GOTO COMPUTERNAME)
@if /I "%yn%"=="n" (GOTO COMPUTERNAME)
@if /I "%yn%"=="y" (GOTO HAMACHIC) else (echo Invalid Entry) & (GOTO FILENAME)
@:HAMACHIC
@pause
@echo "ComputerName %ComputerN" > test.txt
@echo "AutoNetwork <BNS_VPN>" >> test.txt
@echo "AutoPassword <password>" >> test.txt
@echo "ChatColorLogBack 000000" >> test.txt
@echo "ChatColorLogFore FFFFFF" >> test.txt
@echo "ChatColorLogSelf 528B8B" >> test.txt
@echo "ChatColorLogPeer CFDBC5" >> test.txt
@echo "ChatColorLogSystem CC99CC" >> test.txt
@echo "ChatColorLogNetwork C2C2C2" >> test.txt
@echo "ChatColorLogHistory CDCDCD" >> test.txt
@echo "NoTrayBalloons 1" >> test.txt
@pause

i can't have the "" in the file, if i take them out i get errors because of >'s in the data.

Thanks

Re: Saving input from batch into text file [Partially complete]

Posted: 06 Feb 2010 02:19
by DosItHelp
bre,
You will need to escape special characters like this:

Code: Select all

@echo AutoNetwork ^<BNS_VPN^>  >> test.txt

Optionally use FOR command like this:

Code: Select all

(for %%A in (
        "ComputerName %ComputerN"
        "AutoNetwork <BNS_VPN>"
        "AutoPassword <password>"
        "ChatColorLogBack 000000"
        "ChatColorLogFore FFFFFF"
        "..."
    ) do echo.%%~A
)>"test.txt"


DosItHelp?

Re: Saving input from batch into text file [Partially complete]

Posted: 12 Feb 2010 11:11
by Stergioss
I don't understand why people use @!!!
Use a

Code: Select all

@Echo off
in the start of the batch file!
Much easier!