Batch file issue


ordnance1

New member
Local time
7:25 AM
Posts
13
OS
Windows 11
I have created a batch file that works perfectly on 2 other computers, but on the 3rd computer the line:
Code:
COPY C:\Users\%USERNAME%\OneDrive\Eagles_GrandReceiver_Distribution\MasterFile\Eagles_GrandReceiver_Master.accdb
Is not creating the copy of the file and placing it in C:\FECopy_GrandReceiver.

If I type C:\Users\%USERNAME%\OneDrive\Eagles_GrandReceiver_Distribution\MasterFile in file explorer, it takes me to the correct folder where Eagles_GrandReceiver_Master.accdb exists.

Should mention the 2 computers that work are windows 11 machine and the one not working is a windows 10 machine. Can't imagine that makes a difference but thought I should mention it.

Code:
@echo on

set DRIVE=none

if exist "D:\OneDrive\Eagles_GrandReceiver" set DRIVE=D
    if %drive% ==D GOTO D_Drive

if exist "C:\Users\%USERNAME%\OneDrive\Eagles_GrandReceiver_Distribution" set DRIVE=C
    if %drive% ==C GOTO C_Drive

:C_Drive
    mkdir C:\FECopy_GrandReceiver
        COPY C:\Users\%USERNAME%\OneDrive\Eagles_GrandReceiver_Distribution\MasterFile\Eagles_GrandReceiver_Master.accdb "C:\FECopy_GrandReceiver\Eagles_GrandReceiver_Copy.accdb"
                rem   C:\Users\Mike Simonds\OneDrive\Eagles_GrandReceiver_Distribution\MasterFile\Eagles_GrandReceiver_Master.accdb


            Start /wait C:\FECopy_GrandReceiver\Eagles_GrandReceiver_Copy.accdb"
                @RD /S /Q "C:\FECopy_GrandReceiver"
    EXIT /b

:D_Drive
     mkdir C:\FECopy_GrandReceiver
        COPY D:\OneDrive\Eagles_GrandReceiver\Distribution\MasterFile\Eagles_GrandReceiver_Master.accdb "C:\FECopy_GrandReceiver\Eagles_GrandReceiver_Copy.accdb"
            Start /wait C:\FECopy_GrandReceiver\Eagles_GrandReceiver_Copy.accdb"
                rem DEL C:\FECopy_GrandReceiver\Eagles_GrandReceiver_Copy.accdb"
                @RD /S /Q "C:\FECopy_GrandReceiver"
    EXIT /b

:END
 

My Computer

System One

  • OS
    Windows 11
My guess would be the database file is locked. Copy won't work in that scenario.
 

My Computer

System One

  • OS
    Windows 11
No, it's not locked. I tried running the batch fille on the other 2 computers and it works fine.
 

My Computer

System One

  • OS
    Windows 11
What happens when you attempt to copy the file without using a batch script? Any error messages?
 

My Computer

System One

  • OS
    Windows 11, Windows 10, Linux Fedora Cinnamon
I copied it and it works.

Well not completely true it does take about 4 seconds to download from onedrive.

How can I add a 5 second pause to the code to see if that helps?
 

My Computer

System One

  • OS
    Windows 11
Is your OneDrive's Files On-Demand setting (Settings tab of OneDrive Settings) enabled or disabled (checked or unchecked) on all three computers?
 

My Computers

System One System Two

  • OS
    Windows 11 23H2 Current build
    Computer type
    PC/Desktop
    Manufacturer/Model
    HomeBrew
    CPU
    AMD Ryzen 9 3950X
    Motherboard
    MSI MEG X570 GODLIKE
    Memory
    4 * 32 GB - Corsair Vengeance 3600 MHz
    Graphics Card(s)
    EVGA GeForce RTX 3080 Ti XC3 ULTRA GAMING (12G-P5-3955-KR)
    Sound Card
    Realtek® ALC1220 Codec
    Monitor(s) Displays
    2x Eve Spectrum ES07D03 4K Gaming Monitor (Matte) | Eve Spectrum ES07DC9 4K Gaming Monitor (Glossy)
    Screen Resolution
    3x 3840 x 2160
    Hard Drives
    3x Samsung 980 Pro NVMe PCIe 4 M.2 2 TB SSD (MZ-V8P2T0B/AM) } 3x Sabrent Rocket NVMe 4.0 1 TB SSD (USB)
    PSU
    PC Power & Cooling’s Silencer Series 1050 Watt, 80 Plus Platinum
    Case
    Fractal Design Define 7 XL Dark ATX Full Tower Case
    Cooling
    NZXT KRAKEN Z73 73.11 CFM Liquid CPU Cooler (3x 120 mm push top) + Air 3x 140mm case fans (pull front) + 1x 120 mm (push back) and 1 x 120 mm (pull bottom)
    Keyboard
    SteelSeries Apex Pro Wired Gaming Keyboard
    Mouse
    Logitech MX Master 3S | MX Master 3 for Business
    Internet Speed
    AT&T LightSpeed Gigabit Duplex Ftth
    Browser
    Nightly (default) + Firefox (stable), Chrome, Edge
    Antivirus
    Defender + MB 5 Beta
  • Operating System
    ChromeOS Flex Dev Channel (current)
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude E5470
    CPU
    Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 2501 Mhz, 2 Core(s), 4 Logical Processor(s)
    Motherboard
    Dell
    Memory
    16 GB
    Graphics card(s)
    Intel(R) HD Graphics 520
    Sound Card
    Intel(R) HD Graphics 520 + RealTek Audio
    Monitor(s) Displays
    Dell laptop display 15"
    Screen Resolution
    1920 * 1080
    Hard Drives
    Toshiba 128GB M.2 22300 drive
    INTEL Cherryville 520 Series SSDSC2CW180A 180 GB SATA III SSD
    PSU
    Dell
    Case
    Dell
    Cooling
    Dell
    Mouse
    Logitech MX Master 3S (shared w. Sys 1) | Dell TouchPad
    Keyboard
    Dell
    Internet Speed
    AT&T LightSpeed Gigabit Duplex Ftth
The issue is with:

Code:
COPY C:\Users\%USERNAME%\OneDrive\Eagles_GrandReceiver_Distribution\MasterFile\Eagles_GrandReceiver_Master.accdb

The batch file returns The System cannot find the file specified. If I put the path in File Explorer, it opens the database.
 

My Computer

System One

  • OS
    Windows 11
If the username contains spaces or special characters, you may have to enclose the path and filename in quotes.

COPY "C:\Users\%USERNAME%\OneDrive\Eagles_GrandReceiver_Distribution\MasterFile\Eagles_GrandReceiver_Master.accdb" "C:\FECopy_GrandReceiver\Eagles_GrandReceiver_Copy.accdb"

Ben
 

My Computer

System One

  • OS
    Windows 10 Home
    Computer type
    Laptop
    Manufacturer/Model
    HP Elitebook 2530p
    CPU
    Intel Core 2 Duo L9400@1.86 GHz
    Memory
    2 GB
Code:
COPY "C:\Users\%USERNAME%\OneDrive\Eagles_GrandReceiver_Distribution\MasterFile\Eagles_GrandReceiver_Master.accdb" "C:\FECopy_GrandReceiver\Eagles_GrandReceiver_Copy.accdb"

Ben
 

My Computer

System One

  • OS
    Windows 10 Home
    Computer type
    Laptop
    Manufacturer/Model
    HP Elitebook 2530p
    CPU
    Intel Core 2 Duo L9400@1.86 GHz
    Memory
    2 GB
Thank you to everyone it was in fact the missing " " that was causing the problem. Odd that it worked on the other computers.
 

My Computer

System One

  • OS
    Windows 11
Thank you to everyone it was in fact the missing " " that was causing the problem. Odd that it worked on the other computers.
The others did not have a username with a space or special character in it.
 

My Computers

System One System Two

  • OS
    Windows 11 23H2 Current build
    Computer type
    PC/Desktop
    Manufacturer/Model
    HomeBrew
    CPU
    AMD Ryzen 9 3950X
    Motherboard
    MSI MEG X570 GODLIKE
    Memory
    4 * 32 GB - Corsair Vengeance 3600 MHz
    Graphics Card(s)
    EVGA GeForce RTX 3080 Ti XC3 ULTRA GAMING (12G-P5-3955-KR)
    Sound Card
    Realtek® ALC1220 Codec
    Monitor(s) Displays
    2x Eve Spectrum ES07D03 4K Gaming Monitor (Matte) | Eve Spectrum ES07DC9 4K Gaming Monitor (Glossy)
    Screen Resolution
    3x 3840 x 2160
    Hard Drives
    3x Samsung 980 Pro NVMe PCIe 4 M.2 2 TB SSD (MZ-V8P2T0B/AM) } 3x Sabrent Rocket NVMe 4.0 1 TB SSD (USB)
    PSU
    PC Power & Cooling’s Silencer Series 1050 Watt, 80 Plus Platinum
    Case
    Fractal Design Define 7 XL Dark ATX Full Tower Case
    Cooling
    NZXT KRAKEN Z73 73.11 CFM Liquid CPU Cooler (3x 120 mm push top) + Air 3x 140mm case fans (pull front) + 1x 120 mm (push back) and 1 x 120 mm (pull bottom)
    Keyboard
    SteelSeries Apex Pro Wired Gaming Keyboard
    Mouse
    Logitech MX Master 3S | MX Master 3 for Business
    Internet Speed
    AT&T LightSpeed Gigabit Duplex Ftth
    Browser
    Nightly (default) + Firefox (stable), Chrome, Edge
    Antivirus
    Defender + MB 5 Beta
  • Operating System
    ChromeOS Flex Dev Channel (current)
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude E5470
    CPU
    Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 2501 Mhz, 2 Core(s), 4 Logical Processor(s)
    Motherboard
    Dell
    Memory
    16 GB
    Graphics card(s)
    Intel(R) HD Graphics 520
    Sound Card
    Intel(R) HD Graphics 520 + RealTek Audio
    Monitor(s) Displays
    Dell laptop display 15"
    Screen Resolution
    1920 * 1080
    Hard Drives
    Toshiba 128GB M.2 22300 drive
    INTEL Cherryville 520 Series SSDSC2CW180A 180 GB SATA III SSD
    PSU
    Dell
    Case
    Dell
    Cooling
    Dell
    Mouse
    Logitech MX Master 3S (shared w. Sys 1) | Dell TouchPad
    Keyboard
    Dell
    Internet Speed
    AT&T LightSpeed Gigabit Duplex Ftth

Latest Support Threads

Back
Top Bottom