Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

batch/CMD move does not work with folders

I have a simple .bat (move.bat) file in the SendTo folder which moves files and directories from any location to a specified folder by using the context menu. This worked on XP. In Windows 7 however i get an access denied error. It doesn't even work with cmd opened as admin (runas).

content of move.bat:

move %1 c:\specifiedfolder
like image 673
spoekes Avatar asked Apr 09 '26 15:04

spoekes


2 Answers

I had this same issue so did a bit of experimenting.

It seems that as of Windows 7, ANY open handle to the directory in windows will cause an access denied. This includes explorer open in that directory, and people using that directory over the network.

You can use rename if you are renaming a directory but otherwise keeping the path the same. This will work EVEN if there is an open handle such as an explorer window open within that directory (the path within the window will get refreshed) Which is a good solution if you are just trying to backup information as a fail-safe, but not anything you are likely to use for automated network backing up etc.

if the permissions settings did not work, then it is almost certainly an open handle from explorer, an executable running from that directory or some thing similar.

like image 85
David Frenkel Avatar answered Apr 11 '26 09:04

David Frenkel


In Windows 7 you have to run the batch as administrator. But then make sure to change dir to homedir at begginning of your script, coz current dir will be different than what it should be when you run as admin..

Alternatively you can start a cmd window with admin rights then you can type or drag&drop batch files into it...

another way to do is to xcopy with /R option, then delete source... Or simply use robocopy

robocopy %1 c:\specifiedfolder /E /IS /MOVE

but still you need to dele skipped files...

like image 29
Aziz Avatar answered Apr 11 '26 10:04

Aziz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!