You’ve nailed it: the task’s “run-as” account can’t authenticate to the remote share, so every UNC access fails with “The user name or password is incorrect.” When you double‑click, your interactive credentials (or saved creds) are used; Task Scheduler uses the account shown on the task’s General tab.
Do one of these (pick one):
Option A — Run the task as an account that already has access
1) On the destination PC, ensure a user exists that has NTFS + Share permissions on \OtherPC\Share (e.g., BackupUser; must have a non‑blank password).
2) On the source PC, open Task Scheduler > your task > General > “When running the task, use the following user account” = that same user (domain\user or OTHERPC\BackupUser). Keep “Run whether user is logged on or not,” enter the password.
3) Re‑run the task.
Option B — Store credentials for the task’s user (no passwords in scripts)
1) Sign in as the same user the task runs as.
2) Open Control Panel > Credential Manager > Windows Credentials > Add a Windows credential.
3) Internet or network address: \OtherPC (or its hostname).
4) Username:
- If target uses a local account: OTHERPC\BackupUser
- If target uses a Microsoft account: MicrosoftAccountyouremail@example.com
5) Enter the password, save, then re‑run the task.
Option C — Pre‑auth inside the .bat (quickest, but exposes a password)
Add at the top of your .bat:
net use \OtherPC\Share /user:OTHERPC\BackupUser "P@ssw0rd!" /persistent:no
rem … your XCOPY lines …
net use \OtherPC\Share /delete /y
Avoid this if you can; plaintext creds are risky.
Notes and quick checks
- For a one‑time test, set General > Run only when user is logged on and click Run. If it works, it’s definitely credentials.
- If the destination uses a Microsoft account, the username format matters: MicrosoftAccountyouremail@example.com.
- “Run with highest privileges” is fine, but unrelated to SMB auth.
- Your logging line was perfect; after the change, dir \OtherPC\Share in the task context should list files.
If you tell me which model you prefer (A, B, or C) and what the target account is (local vs Microsoft/domain), I’ll give you the exact fields to fill and a quick permission checklist on the share.