I'm running a robocopy script to backup a server and I'm using net stop
and taskkill
to terminate services and processes that could cause the script to fail or miss important files, but how do I close any open files or folders on network shares (in case a client PC left stuff open when they went home)??
There are two ways you can do this easily via a batch script:
NET SESSION \\computername /delete
or
SC RESTART LanmanServer
The first terminates all sessions for the specified computer name. The latter stops and restarts the file server, which would effectively terminate all sessions.