Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Batch file question, with Vista

Posted on 2009-05-10
10
Medium Priority
?
893 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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 71

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 71

Accepted Solution

by:
Qlemo earned 2000 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

730 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