Run batch as ADMIN & use robocopy
5,483
Re-establish B:
mapping:
powercfg -change -standby-timeout-ac 0
if not exist B:\desktop\nul net use B: \\ComputerName\ShareName /PERSISTENT:No
robocopy "C:\USER\DESKTOP\" "B:\DESKTOP"
powercfg -change -standby-timeout-ac 1
shutdown /s -t 0
or, with different test:
powercfg -change -standby-timeout-ac 0
net use b:
if %errorleve% NEQ 0 net use B: \\ComputerName\ShareName /PERSISTENT:No
robocopy "C:\USER\DESKTOP\" "B:\DESKTOP"
powercfg -change -standby-timeout-ac 1
shutdown /s -t 0
Related videos on Youtube
Author by
Guilherme Ramos
Updated on September 18, 2022Comments
-
Guilherme Ramos over 1 year
I need to copy from
%USERPROFILE%\Desktop
toB:\Desktop
where B is a mapped network drive. The code inside BAT file is:powercfg -change -standby-timeout-ac 0 robocopy "C:\USER\DESKTOP\" "B:\DESKTOP" powercfg -change -standby-timeout-ac 1 shutdown /s -t 0
In line 1, I want that windows never suspend, turn off, go to screensaver... Just stay awake. Then run robocopy, I'm using "/XJ /E /Z /R:5 /W:1" in the BAT that actually work. Line 3 is to set that win7 can do whatever it wants, just to not stay awake. Then it turn off the computer.
That's what i get:
------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy para Windows ------------------------------------------------------------------------------- Iniciado: Tue Jan 27 15:17:08 2015 2015/01/27 15:17:08 ERRO 3 (0x00000003) Obtendo Tipo de Sistema de Arquivos do D estino B:\TESTE\ O sistema não pode encontrar o caminho especificado. Origem : C:\USER\DESKTOP\ Dest - B:\DESKTOP\ Arquivos: *.* Opções: *.* /COPY:DAT /R:1000000 /W:30 ------------------------------------------------------------------------------ 2015/01/27 15:17:08 ERRO 3 (0x00000003) Criando Diretório de Destino B:\TESTE\ O sistema não pode encontrar o caminho especificado.
It IS in portugues, but the message is the classic error 3 one.
If I run as Admin, wich is necessarily to use powercfg, the robocopy will not run. If I run as user, robocopy run normally but I cant use powercfg.
What to do?
-
Guilherme Ramos over 9 yearsJust tried, my colleague is Admin on server. She created a folder using Admin account and yet it does not worked as expected.
-
-
Guilherme Ramos over 9 yearsThat worked, Thanks <br>I cant set to pc never turn off now
-
Guilherme Ramos over 9 yearsI re-worked on that and I got exactly what I want. A hint for those who wish to do something similar: nothing that is written on my question "code" actually work.