Solved

Batch file question, with Vista

Posted on 2009-05-10
10
878 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 68

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 68

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now