Jump to content

Help producing a batch script.


Recommended Posts

Posted (edited)

Hey there guys, I had a question that's been confusing me lately and I apologise if it seems stupid, but at the moment I am just experimenting with batch scripts, and I came across a small prob which I haven't been able to figure out yet.

Heres a brief example:

Lets say I made a batch file on my C:\ and called it "make.bat" and I wanted it to produce the following below, into another batch file, "C:\test\run.bat" so the new file (run.bat) will contain only:

" echo Hello world. >> C:\DOCUME~1\ALLUSE~1\Desktop\Readme.txt " ...without speech marks

what would I put in the original batch file (make.bat), to create that?, so basically, what I would want is:

1.) You run "C:\make.bat"

2.) "C:\make.bat" creates "C:\test\run.bat"

3.) When "C:\test\run.bat" is executed is creates Readme.txt on your desktop.

i've already tried:

echo "echo Hello world. >> C:\DOCUME~1\ALLUSE~1\Desktop\Readme.txt" >> C:\test\run.bat

but then C:\test\run.bat is created with speech marks inside it, which then makes the batch file unable to work..

I know it seems kind of confusing but i'd appreciate any help. :)

Thanks in advance.

- Jason

Edited by csgecko

Posted

Well basically, all I wanted to do was to make a batch file for my friend, so when he runs it, it creates a batch file in his startup folder, which creates the readme on his desktop everytime the comp starts up.

Posted

oh i see so your not in a domain environment then.

i think maybe a vb script would be better suited for this task.. as to how to do it though, you'll have to ask someone else im afraid, im really rusty on VB, havent looked at it in ages lol :)

Posted

Try something like this

1:@ECHO OFF
2:IF NOT EXIST C:\TEST MD C:\test
3:PUSHD C:\TEST
4:>run.bat ECHO/^>"C:\DOCUMENTS AND SETTINGS\ALL USERS\DESKTOP\Readme.txt" ECHO/Hello world
5:RUN.BAT

Remove the line numbers from all 5 lines before you attempt to run it

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...