Solved

Batch file question, with Vista

Posted on 2009-05-10
10
884 Views
Last Modified: 2012-05-06
Ok i am incredibly unfamiliar with batch files. Im trying to get one to work in windows Vista.
everytime i run the batch file it displays "the system cannot find the file specified"

This is whats in the batch file:
FOR /F "tokens=*" %%D IN ('DIR "C:\Program Files\amtlib.dll" /S /B') DO copy /Y "amtlib.dll" "%%D"
pause

Now the amtlib.dll is in the same file as the batch file, and I am running it as an administrator.
I think im using windows vista.

So the question is how do i get the .bat file to work? thanks!
0
Comment
Question by:Kashis
  • 6
  • 2
  • 2
10 Comments
 
LVL 5

Expert Comment

by:sykojester
ID: 24349792
"Now the amtlib.dll is in the same file as the batch file, and I am running it as an administrator.
I think im using windows vista. "

amtlib.dll must be in the same folder as the batch file unless you specify the full path.

I just ran a test using your script on my machine (substituting amtlib.dll with blah.txt) and had no issues.  I also had a different copy of blah.txt in the same working directory as my batch file.

Are you clicking on the batch file to execute it or using something else to call it?  If you're using something else to call it you may need to specify the full path of the file you're wanting to copy.
0
 

Author Comment

by:Kashis
ID: 24349917
im right clicking on it and hitting run as administrator. i think i have the 64 bit version of windows, im not sure tho
0
 

Author Comment

by:Kashis
ID: 24349959
They are in the same folder. I dont know why its not working
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 5

Expert Comment

by:sykojester
ID: 24349970
Verify that your file path is correct & the file is there; C:\Program Files\amtlib.dll

If you're running Vista 64 the path may be C:\Program Files (x86)\

Also verify that your file amtlib.dll is in the same directory as the batch file your executing.  

Optionally you can provide the full path to the file your copying (source file).

i.e.
FOR /F "tokens=*" %%D IN ('DIR "C:\Program Files\amtlib.dll" /S /B') DO copy /Y "C:\Users\UserName\Desktop\amtlib.dll" "%%D"

This assumes that you're amtlib.dll file is on the desktop of user called 'UserName'.  Adjust the path to where the file is located accordingly.
0
 

Author Comment

by:Kashis
ID: 24350036
still saying the file cant be found.
ive tried having the batch file in the same directory as the .dll file
ive tried what you said, neither is working.

Im on a Sony Vaio, if that helps
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 24350210
To make sure the amtlib.dll is taken out of the same folder as the batch file, add this:

FOR /F "tokens=*" %%D IN ('DIR "C:\Program Files\amtlib.dll" /S /B') DO copy /Y "%%~dpDamtlib.dll" "%%D"

Open in new window

0
 

Author Comment

by:Kashis
ID: 24350302
I did as Qlemo said and it said that the file cannot be copied onto itself.
the batch file is in a folder on the desktop. so its not in the program file directory.
I think we are making progress tho
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 24350313
Sorry, big mistake, I used the path of the DLL instead of that of the batch. %~dp0 will result in drive (d) and path (p) of %0, which is the executing file = batch.

FOR /F "tokens=*" %%D IN ('DIR "C:\Program Files\amtlib.dll" /S /B') DO copy /Y "%~dp0amtlib.dll" "%%D"

Open in new window

0
 

Author Comment

by:Kashis
ID: 24350332
wow your good. that worked.
Thanks!
0
 

Author Closing Comment

by:Kashis
ID: 31579972
YOUR THE BEST! THANKS!!!!!!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question