![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2006
Posts: 13
Rep Power: 0
![]() |
Create a new batch file
Does anyone know how to make a .bat file that will create another .bat file to a specific directory and run a command when opened? Does any one have any ideas? Thanks
|
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4
![]() |
touch /some/dir/newfile echo ls>>/some/dir/newfile chmod 700 /some/dir/newfile
__________________
PFO - My daily dose of technology. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jan 2006
Posts: 13
Rep Power: 0
![]() |
Maybe I'm jsut retarded here but no matter what I put in "dir" or anywhere I can't get the new file to be created in anything but "C:\" and I want it in "C:\Documents and Settings"
|
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
@infogeek: I think Steiner is talking windows, not linux.
@steiner: Open a batch file, say 1.bat and put echo some command >c:\docume~1\file2.bat If you want to append to the file every time you run 1.bat, use echo some command >>c:\docume~1\file2.bat |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jan 2006
Posts: 13
Rep Power: 0
![]() |
thanks alot I'll specify Windows next time, sorry about that
|
|
|
|
|
|
#6 |
|
Hobbyist Programmer
|
What you might want to do is include the whole path c:\dir\me.bat or do cd dir then create it.
|
|
|
|
|
|
#7 | |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Quote:
echo some command >>c:\docume~1\file2.bat |
|
|
|
|
|
|
#8 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 314
Rep Power: 4
![]() |
Just an aside, if you don't like the artificially shortened version of the directory name, you can actually use spaces in filenames on the command line in recent versions of Windows by surrounding the filename with quotes, like:
echo some command >> "C:\Documents and Settings\file2.bat" I haven't tested this (don't have a Windows machine) but it should work. Just remember the quotes have to go around the whole path, not just the parts of it that wouldn't work without them. This works for long filenames and filenames with 'invalid' characters. Off the top of my head, I'm not sure how you include a quote in this; I'd expect doubling up the quotes would do. You probably won't have to do this anyway but I think: C:\> echo test > "file with ""quotes"" in name" should create a file called file with "quotes" in name It might not, but doubling up otherwise invalid characters in strings is usually the way to deal with them on Windows. Hope this helps.
__________________
"I'm not a genius. Why do I have to suffer?" |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|