Jump to content

Recommended Posts

Posted

Batch Programming or VBScripting

In Batch Programming and VBScripting i will input info into a document; but it adds the info to the end of the last info of the document, how can i make it put it on the lower line?

Windows Hosts File Example:

Original File

127.0.0.1 localhost

After The Data

127.0.0.1 localhost

127.0.0.1 testsite.com ( Lower line )

Wrong Data

127.0.0.1 localhost127.0.0.1 testsite.com


Posted

Hmmm, probably the original document misses a Carriage return/Line feed as last character.

Send a CR+LF before adding the data, BATCH example

ECHO. >>thedoc.ext
ECHO 127.0.0.1 testsite.com >>thedoc.ext

or maybe easier :

(ECHO.
ECHO 127.0.0.1 testsite.com
) >>thedoc.ext

jaclaz

Posted (edited)

sorry i understand

can you please adapt it to my code?

My Code:

echo 127.0.0.1 testsite.com>> %SYSTEMROOT%\system32\drivers\etc\hosts

Thnx for concern

Edited by Ortakey
Posted

You shouldn't be trying to alter the output command, you should be fixing the file!

Something like this should fix the file.

@Echo off&Pushd %SystemRoot%\System32\drivers\etc
More HOSTS>HOSTS.bak&&(Del HOSTS&&Ren HOSTS.bak HOSTS)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...