Package - moving a file to a network drive without logging in

I have the following script, which is configured as a task to automatically move a file to a mapped network drive. The problem is that this only works when a user logs in and opens an active Windows session. However, if the user is logged off, these backups will not be performed because I believe that he cannot find the network drive. This runs on a Windows 2003 server. Is there a way to modify the script to make sure that it can connect to a network drive while active sessions are not open?

The process I use is to move the file, then delete the file to clear the hard disk space, and then run .exe to empty the recycle bin.

@echo off move C:\StarshipBackup\*.* Z:\StarshipDataBackup del C:\StarshipBackup\*.* /F /Q C:\emptyrecycle.exe 
+4
source share
1 answer

You can mount the drive in a batch file. Add this before your move command:

 net use z: \\yourserver\sharename 

Of course, you need to make sure that the account that the batch file is working with has permission to access the resource. If you do this using a scheduled task, you can select an account by selecting a task, and then:

  • right click properties
  • Click the General tab on the General tab in the
  • "Use the following account to complete the task:"

What in Windows 7 may differ in different versions of Windows.

+4
source

Source: https://habr.com/ru/post/1501650/


All Articles