Click to See Complete Forum and Search --> : Batch file commands needed!


a ronin
04-12-2003, 12:29 PM
Hi,

Well I caught a thread in here with regards to making batch files to automate certain tasks. I'm inept with programming; even in DOS commands. What I'm trying to do is make a batch file that opens up dos prompt and upon execution it will show ipconfig (for one example).

So far I've:

file.bat
(%SystemRoot%\system32\cmd.exe"-.exe ipconfig /all)


() denotes contents of .bat file

This to me seems to be working, except it will only show it instantenously then close off again. It's like typing ipconfig in the RUN command which will quickly pop up the command prompt then shut down.

Help?

Thanks

biscuitbandit
04-12-2003, 03:59 PM
put in another line below that simply saying 'pause' that waits until u hit enter or whatever

plus the command you are entering is to run a command prompt, a batch file IS a command prompt, there for all you need is to have a file called say "ip.bat" then two lines in it saying

ipconfig /all
pause

muisejt
04-12-2003, 04:06 PM
all you need in the batch file is

ipconfig /all
pause

the pause will cause the window to stay open by pausing, when you hit enter the script will continue and since there is nothing else to do it closes

[edit]beat by a few minutes :( ;)

a ronin
04-12-2003, 07:55 PM
Hahahaha! Thanks guys! :)

Do you have any ideas/suggestions on what else one could use batch 'programming' to make windows cool ? this is really cool.


Thanks again!

Handyman
04-13-2003, 02:21 AM
I've been using a batch file for about a month now to automatically backup any new files in a certain directory from one computer to another. Here are the contents of this batch file:



@ECHO OFF
ECHO Backing Up System Files >>mp3log.txt
datestamp
ECHO =================================================== >>mp3log.txt
XCOPY F:\MCS_Files\Audio_Files C:\Backup /E /V /H /R /K /Y /D /C /I >>mp3log.txt
ECHO =================================================== >>mp3log.txt
ECHO Backup Completed >>mp3log.txt
ECHO - >>mp3log.txt
CLS



This batchfile also creates a log of what files have been copied. I also created a simple C program to date stamp the log file (since win98 won't do it thru DOS commands :()

The ECHO command writes the text to the file after the >> sign. Also putting the >> sign and file name after commands writes the info that would have been displayed on screen into the file.

XCOPY and the switches after copy new files and files that have been updated (newer) from one directory to another (in this case from F: to C: )

The batch file is run nightly via the scheduling agent built into windows.

This is the only use I found for a batch so far in my daily computing adventures... tho I'm always on the look out for more :)

Skeelo
04-17-2003, 04:30 PM
Why your MP3s are important enough to backup, I do not know! Anyway I have a lot of stuff I need to backup so I made some changes to your batchfile:


@ECHO OFF
REM Change NETDIR to include the network path you want your backups stored in
set NETDIR=X:\Backups
ECHO Backing up %1 to %NETDIR% >>backups.log
date /t >> backups.log
time /t >> backups.log
echo +++>> backups.log
ECHO =================================================== >>backups.log
XCOPY %1 %NETDIR% /S /V /H /R /K /Y /C /I >>backups.log
ECHO =================================================== >>backups.log
ECHO Backup Completed >>backups.log
ECHO +++ >>backups.log
ECHO. >>backups.log
ECHO. >>backups.log
echo Backed up %1 to %NETDIR%


Only one problem...it won't copy the directory to the backup dir, just all the files in it. Anyone know how to fix that? /S is supposed to copy all directories and subdirs.