Batch File Troubles

Locked
Kills On Site
Posts: 1741
Joined: Wed Jul 23, 2003 7:00 am

Batch File Troubles

Post by Kills On Site »

In class we have this program called Wave Interactive, it contains tests questions similiar to those on the A+ Exam. The program, Wave Interactive, saves a file called Student.mdb that stores all the test taken information, grades and whatnot. Well this is only useful for the days we take the test then we want to start with a clean slate. Currently we just reinstall the program, it is fairly simple and quick. However I wanted to create a batch file that would automatically delete and copy over a blank slate stored elsewhere on the drive. So far this is what I have
echo off
cd\
cd Program Files
cd Wavetech
cd tests
del Student.mdb
cd..
copy Student.mdb C:\Program Files\Wavetech\tests
exit


As you can see the file is at C:\Program Files\Wavetech\tests\Student.mdb for the clean slate I stored it one level up at C:\Program Files\Wavetech\Student.mdb . My batch file deletes the original just fine, but it won't copy over the clean slate file. All machines are running Windows XP Pro and when we test we are logged in as administrator. Can anyone help me, I consulted Computer Hope with no luck.
[size=92][color=#0000FF]Hugh Hefner for President[/color][/size]
Kills On Site
Posts: 1741
Joined: Wed Jul 23, 2003 7:00 am

Post by Kills On Site »

When I alt- print screen in full screen of a dos promt, with the echo and exit deleted, I get this.

C:\Documents and Settings\Tedder Roberts\Desktop>test.bat

C:\Documents and Settings\Tedder Roberts\Desktop>cd\

C:\>cd Program Files

C:\Program Files>cd Wavetech

C:\Program Files\Wavetech>cd tests

C:\Program Files\Wavetech\tests>del Student.mdb

C:\Program Files\Wavetech\tests>cd..

C:\Program Files\Wavetech>copy Student.mdb C:\Program Files\Wavetech\tests
The syntax of the command is incorrect.

C:\Program Files\Wavetech>

However I don't know what is incorrect.
[size=92][color=#0000FF]Hugh Hefner for President[/color][/size]
Tormentius
Posts: 4108
Joined: Sat Dec 14, 2002 8:00 am

Post by Tormentius »

The command prompt doesn't interpret spaces in a path without placing the path in quotes.
Kills On Site
Posts: 1741
Joined: Wed Jul 23, 2003 7:00 am

Post by Kills On Site »

Thanks Tormentius, works now.
[size=92][color=#0000FF]Hugh Hefner for President[/color][/size]
Tormentius
Posts: 4108
Joined: Sat Dec 14, 2002 8:00 am

Post by Tormentius »

Kills On Site wrote:Thanks Tormentius, works now.

You're welcome.
User avatar
raw
Posts: 2739
Joined: Tue Nov 16, 1999 8:00 am

Re: Batch File Troubles

Post by raw »

I'd make the script a tad more efficient like this...

Code: Select all

@ECHO OFF
del "C:\Program Files\Wavetech\tests\Student.mdb"&copy "C:\Program Files\Wavetech\tests\Student.mdb" "C:\Program Files\Wavetech\tests\"
exit
AmIdYfReAk
Posts: 6926
Joined: Thu Feb 10, 2000 8:00 am

Post by AmIdYfReAk »

or use AutoIT V3 :)
User avatar
raw
Posts: 2739
Joined: Tue Nov 16, 1999 8:00 am

Post by raw »

Real admins script. ;)
AmIdYfReAk
Posts: 6926
Joined: Thu Feb 10, 2000 8:00 am

Post by AmIdYfReAk »

that is a scripting program, and it enables you to do a little more then BAt's :)
+JuggerNaut+
Posts: 22175
Joined: Sun Oct 14, 2001 7:00 am

Post by +JuggerNaut+ »

AmIdYfReAk wrote:that is a scripting program, and it enables you to do a little more then BAt's :)
script kiddie.
Silicone_Milk
Posts: 2237
Joined: Sat Mar 12, 2005 10:49 pm

Post by Silicone_Milk »

+JuggerNaut+ wrote:
AmIdYfReAk wrote:that is a scripting program, and it enables you to do a little more then BAt's :)
script kiddie.
:olo:
Locked