Solved Adding a entry to the Windows path


BEH

New member
Local time
8:11 AM
Posts
25
OS
Windows 11 HOME
I added a couple of directories to my Windows PATH. For the purpose of testing the access to them,
they were added to both the USER and SYSTEM PATHS (I know I really need to only add them to one or the other
but I was interested in testing the process and then was going to remove the SYSTEM entry).

The folder hierarchy is this: C:\FDR ONE\FDR-TWO\FDR-THREE
\ FDR-FOUR

I added this to both PATHS: C:\FDR ONE\FDR-TWO and then for the purpose of additional testing
I edited the PATHS to this: C:\FDR ONE\FDR-TWO\

FDR-TWO contains: - test2.txt

FDR-THREE contains: - test3.txt
- TEST-BAT.BAT

FDR-FOUR contains: - test4.txt

I ran all tests in CMD and from this dir. - C:\FDR ONE\FDR-TWO\FDR-THREE

TEST 1: started TEST.BAT containing: myapp <test3.txt > test3.out 2> test3.err - worked OK
TEST 2: started TEST.BAT containing: myapp <test2.txt > test2.out 2> test2.err - The system cannot find the file specified.
TEST 3: started TEST.BAT containing: myapp <test4.txt > test4.out 2> test4.err - The system cannot find the file specified.

AS long as I used the TXT file in the same folder as the .BAT I didn't have an issue. However accessing the TXT files
in the other directories failed consistently. So, it appears that Windows is not checking the folders I added to the PATHS.

I must have missed something but don't know what that could be. I thought I had added the new PATH correctly. The
env. variables for both USER and SYSTEM display with my folders path at the bottom of the lists.

Does anyone have any suggestions to address my issue?

thanks

Edition Windows 11 Home
Version 22H2
Installed on ‎8/‎27/‎2023
OS build 22621.2283
Experience Windows Feature Experience Pack 1000.22662.1000.0

Device name BRIAN
Processor 13th Gen Intel(R) Core(TM) i5-1335U 1.30 GHz
Installed RAM 32.0 GB (31.7 GB usable)
Device ID 41EC106D-93F3-49AB-A5E2-F3ED7AF3131E
Product ID 00342-22174-08151-AAOEM
System type 64-bit operating system, x64-based processor
Pen and touch No pen or touch input is available for this display
 

My Computer

System One

  • OS
    Windows 11 HOME
    Computer type
    Laptop
    Manufacturer/Model
    HP LAPTOP 17 - cn3xxx
    CPU
    13th Gen Intel(R) Core(TM) i5-1335U 1.30 GHz
    Memory
    32.0 GB (31.7 GB usable)
    Hard Drives
    2 TB
I edited the PATHS to this: C:\FDR ONE\FDR-TWO\
By doing that the path was broken, Windows is being told to look for a different set of folders and can't find them. It's a computer-age-old situation, learned it back with my first computer in '92 with MS-DOS 5 and WIndows 3.1 and before that with some employer training.
 

My Computers

System One System Two

  • OS
    Win11 Pro RTM
    Computer type
    Laptop
    Manufacturer/Model
    Dell Vostro 3400
    CPU
    Intel Core i5 11th Gen. 2.40GHz
    Memory
    12GB
    Hard Drives
    256GB SSD NVMe
  • Operating System
    Windows 11 Pro RTM x64
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Vostro 5890
    CPU
    Intel Core i5 10th Gen. 2.90GHz
    Memory
    16GB
    Graphics card(s)
    Onboard, no VGA, using a DisplayPort-to-VGA adapter
    Monitor(s) Displays
    24" Dell
    Hard Drives
    512GB SSD NVMe, 2TB WDC HDD
    Browser
    Firefox, Edge
    Antivirus
    Windows Defender/Microsoft Security
I ran all tests in CMD and from this dir. - C:\FDR ONE\FDR-TWO\FDR-THREE
If you type PATH (with no parameters) from a CMD Window, what does it say?
 

My Computers

System One System Two

  • OS
    Windows 11
    Computer type
    PC/Desktop
    CPU
    AMD Ryzen 5 5600
    Motherboard
    MSI B550-A Pro
    Memory
    16 GB
    Graphics Card(s)
    Sapphire Radeon RX 6500XT (8 GB version)
    Monitor(s) Displays
    BenQ Mobuiz EX2710Q QHD, Iiyama ProLite X23377HDS
    Hard Drives
    MSI Spatium M461 4TB
  • Operating System
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Acer A114
    CPU
    Intel Celeron N4020
The PATH variable only searches for executable files to run, it doesn't look for normal files in another folder.

What you should do is allow command-line arguments to TEST.BAT, and add its folder location to PATH. Now you can call TEST.BAT from any random folder.
Code:
@echo off
setlocal enabledelayedexpansion
if [%1] NEQ [] (
   set "file=%~n1"
   myapp < "!file!.txt" > "!file!.out" 2> "!file!.err"
)
endlocal

TEST.BAT text3.txt
TEST.BAT ..\test2.txt
TEST.BAT FDR-FOUR\test4.txt
TEST.BAT "C:\Users\BEH\Documents\Test File With Spaces In Name.txt"
 

My Computer

System One

  • OS
    Windows 7
OK... thanks for your responses... I know how to proceed from them....
 

My Computer

System One

  • OS
    Windows 11 HOME
    Computer type
    Laptop
    Manufacturer/Model
    HP LAPTOP 17 - cn3xxx
    CPU
    13th Gen Intel(R) Core(TM) i5-1335U 1.30 GHz
    Memory
    32.0 GB (31.7 GB usable)
    Hard Drives
    2 TB

Latest Support Threads

Latest Tutorials

Back
Top Bottom