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
Share:
5,483

Related videos on Youtube

Guilherme Ramos
Author by

Guilherme Ramos

Updated on September 18, 2022

Comments

  • Guilherme Ramos
    Guilherme Ramos over 1 year

    I need to copy from %USERPROFILE%\Desktop to B:\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
      Guilherme Ramos over 9 years
      Just tried, my colleague is Admin on server. She created a folder using Admin account and yet it does not worked as expected.
  • Guilherme Ramos
    Guilherme Ramos over 9 years
    That worked, Thanks <br>I cant set to pc never turn off now
  • Guilherme Ramos
    Guilherme Ramos over 9 years
    I 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.