0

I have a batch file with three multiple choice options. If I select A, it is supposed to copy a folder called Files (located in the same root directory as the batch file) to the root of the C:\ drive. I can't seem to understand why the %SystemDrive% variable isn't working and wants to point to C:\Windows\system32.

Any ideas?

run.bat

@echo off
set /a _Debug=0
::==========================================
:: Get Administrator Rights
set _Args=%*
if "%~1" NEQ "" (
  set _Args=%_Args:"=%
)
fltmc 1>nul 2>nul || (
  cd /d "%~dp0"
  cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~dp0"" && ""%~dpnx0"" ""%_Args%""", "", "runas", 1 > "%temp%\GetAdmin.vbs"
  "%temp%\GetAdmin.vbs"
  del /f /q "%temp%\GetAdmin.vbs" 1>nul 2>nul
  exit
)

@ECHO OFF
TITLE WINDOWS AUTOMATION UTILITY
COLOR 02
CLS
ECHO.
ECHO THIS UTILITY HELPS AUTOMATE WINDOWS 10
ECHO ======================================
ECHO.
:MENU
ECHO  [A]   Copy 'Files' directory from installation media to System Drive
ECHO  [B]   Set default Start menu for all users
ECHO  [C]   EXIT Remove bloatware apps from Windows 10

choice /C ABC /M "Select Mode:" /N
IF %ERRORLEVEL% EQU 3 goto End
IF %ERRORLEVEL% EQU 2 goto B
IF %ERRORLEVEL% EQU 1 goto A

::
:B
CLS
ECHO THIS IS B
TIMEOUT 2 >nul
CLS
GOTO MENU

::
:A
CLS
ECHO THIS IS A
TIMEOUT 2 >nul
CLS
ROBOCOPY "%~dp0Files" %SystemDrive% /MT
GOTO MENU

::
:End
CLS
ECHO You've reached the end
PAUSE
EXIT 0

Robocopy result

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows
-------------------------------------------------------------------------------

  Started : 23 March 2020 00:15:09
   Source : D:\Users\Will\Documents\IT Projects\Windows\Windows 10 Image\Files\
     Dest : C:\Windows\system32\

    Files : *.*

  Options : *.* /DCOPY:DA /COPY:DAT /MT:8 /R:1000000 /W:30

------------------------------------------------------------------------------

UPDATE

@Durry42 Typing Set into Command Prompt does return C:\

@aschipfl I think I tried appending a backslash at the end of %SystemDrive% and it made no difference.

willowen100
  • 29
  • 1
  • 1
  • 4
  • `%SystemDrive%` just contains a drive specification (usually `C:`); this constitutes a relative path unless you append `\ `to get something like `C:\ `as the destination; otherwise the current directory of `C:` is used, which depends on where and how you started the script. *N. B.:* that's not multiple but *single* choice... – aschipfl Mar 23 '20 at 02:30
  • In a cmd window, run `set` and see what the current value is for the `%SystemDrive%` variable – Durry42 Mar 23 '20 at 05:19

0 Answers0