Saving input from batch into text file [Partially complete]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
bre
Posts: 3
Joined: 05 Feb 2010 04:25

Saving input from batch into text file [Partially complete]

#1 Post by bre » 06 Feb 2010 02:03

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

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

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

#2 Post by DosItHelp » 06 Feb 2010 02:19

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?

Stergioss
Posts: 5
Joined: 12 Feb 2010 10:33

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

#3 Post by Stergioss » 12 Feb 2010 11:11

I don't understand why people use @!!!
Use a

Code: Select all

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

Post Reply