Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Batch file question, with Vista

Posted on 2009-05-10
10
Medium Priority
?
895 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

The Service applet starts in Extended Mode by Default, with a taskpad on the left of the services pane. This view mode was introduced in XP. As I find it not very usefull, I like to use the Standard view as default, and without the Console tree. …
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

886 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