开发者

how create a .bat file that deletes a file on remote server?

开发者 https://www.devze.com 2023-03-15 04:31 出处:网络
I am pretty new to .bat file concept. I have this daily admin task to remotely login on a server and delete the log file. I created a delete.bat file which deletes the desired log file but it works on

I am pretty new to .bat file concept. I have this daily admin task to remotely login on a server and delete the log file. I created a delete.bat file which deletes the desired log file but it works only when it is located locally on that server. If I use the same code (del D:\Logs1\Logs2\a.txt /p) on my local machine and schedule (using at 13:22 \\abc.xyz.com /every:m,t,w,th,f,s,su delete.开发者_开发技巧bat) to run on remote server, it gives me an error that "the network path was not found".

I searched various websites but couldn't find anything, and if I find something, it's highly VB or some other programming language based solution which I don't understand much.

Any help would be great and thank you in advance.


you could try to map that path to a drive (of course you require Write privilege) and delete the files from that drive path.

to add network location (from command line) use: net use x: \\hostname\folder1\folder2

here x: can be replaced with any available drive letter.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号