Solved

Batch file question, with Vista

Posted on 2009-05-10
10
888 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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 70

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 70

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
So who is this article for? If you are like most of the computer users out there, you probably only realize the meaning of 'System maintenance' after something goes wrong. This article is for you if you care about keeping your system working opti…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

624 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