Using mkdir in a batch file to create a directory i Program Files(x86

RBCC

New member
Member
VIP
Local time
7:13 AM
Messages
119
I am trying to get this batch file to work





MKDIR C:\Program Files(x86)\NCH Software\NCH Software\Components
MKDIR C:\Program Files(x86)\NCH Software\NCH Software\Photostage
MKDIR C:\Program Files(x86)\NCH Software\NCH Software\Disketch
MKDIR C:\Program Files(x86)\NCH Software\NCH Software\PhotoPad



but all's I get is this:

subdirectory or file C:\Program already exists.
Error occurred while processing: C:\Program.
A subdirectory or file Files(x86)\NCH already exists.
Error occurred while processing: Files(x86)\NCH.
A subdirectory or file Software\NCH already exists.
Error occurred while processing: Software\NCH.
A subdirectory or file C:\Program already exists.
Error occurred while processing: C:\Program.



how do I rewrite program files(x86) to make this work? John
 

My Computer My Computer

Computer Manufacturer/Model Number
Gateway
OS
Windows 7 Ultimate
CPU
Turion 64 Bit
Memory
2 GIG
It's telling you right there the folders from the program you installed from NCH already exists. Can you confirm?

I use NCH's Wavepad myself, but never had tro use a batch file. Why are you wanting to make a batch file?
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 7 Ultimate x64
Not that I understand why you need a batch file, use MKDIR with a "-p" switch placed in your batch file:
MKDIR -p C:\Program Files(x86)\NCH Software\NCH Software\Components
MKDIR -p C:\Program Files(x86)\NCH Software\NCH Software\Photostage
MKDIR -p C:\Program Files(x86)\NCH Software\NCH Software\Disketch
MKDIR -p C:\Program Files(x86)\NCH Software\NCH Software\PhotoPad
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 7 x64, Vista x64, 8.1 smartphone
CPU
Intel E8400 65W 64-bit
Motherboard
Gigabyte EP45-UD3LR
Memory
DDR2 2 x 2GB, 1GB x 2
Graphics Card(s)
XFX Radeon HD5750
Sound Card
AMD High Definition Audio; Realtek High Definition Audio
Monitor(s) Displays
iiyama prolite X2377HDS
Screen Resolution
1920 x 1080
Hard Drives
500GB 7200 rpm Seagate ST3500413AS 16MB, 500GB 5400 rpm Toshiba MQ02ABF050H 32MB, 200GB 7200 rpm Seagate ST3200820AS 8MB, 2TB 7200 rpm Western Digital WD20EZRX 64MB
PSU
Enermax Liberty Modular
Case
Antec P193 Midi Tower
Keyboard
Mionix ZIBAL 60
Mouse
Razer USB 2.0 Diamondback Mouse or Huion Graphics Tablet
Browser
Internet Explorer, Lunascape, Firefox, Opera, Avast Safezone
The issue is there are names bigger then 8 characters. You have to use path between "
Ex.:
MKDIR C:\Program Files(x86)\NCH Software\NCH Software\Components

replace with

MKDIR "C:\Program Files(x86)\NCH Software\NCH Software\Components"
 
Last edited:

My Computers My Computers

System One System Two

  • Computer type
    PC/Desktop
    Computer Manufacturer/Model Number
    custom build
    OS
    Windows 7 HP 64
    CPU
    i5 6600K - 800MHz to 4200MHz
    Motherboard
    GA-Z170-HD3P
    Memory
    4+4G GSkill DDR4 3000
    Graphics Card(s)
    IG - Intel 530
    Monitor(s) Displays
    Samsung 226BW
    Screen Resolution
    1680x1050
    Hard Drives
    (1) -1 SM951 – 128GB M.2 AHCI PCIe SSD drive for Windows 7 and Lubuntu
    (2) -1 WD SATA 3 - 1T for Data
    (3) -1 WD SATA 3 - 1T for backup
    PSU
    Thermaltake 450W TR2 gold
    Keyboard
    Old and good Chicony mechanical keyboard
    Mouse
    Logitech mX performance - 9 buttons (had to disable some)
    Internet Speed
    500Mb/s
    Browser
    Firefox 64
    Other Info
    TinyWall firewall
  • Computer type
    Laptop
    System Manufacturer/Model Number
    Asus Q550LF
    OS
    Windows 7 Pro
    CPU
    i7-4500U 800MHz to 3.0GHz
    Motherboard
    Asus Q550LF
    Memory
    (4+4)G DDR3 1600
    Graphics Card(s)
    IG intel 4400 + NVIDIA GeForce GT 745M
    Sound Card
    Realtek
    Monitor(s) Displays
    LG Display LP156WF4-SPH1
    Screen Resolution
    1920 x 1080
    Hard Drives
    BX500 120G SSD for Windows and programs +
    1T HDD for data
    Internet Speed
    500 Mb/s
    Browser
    Firefox
    Other Info
    TinyWall firewall
MD "%programfiles(x86)%\NCH Software\NCH Software\Components"
 

My Computers My Computers

System One System Two

  • Computer type
    PC/Desktop
    OS
    7 X64
    CPU
    i5 8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Hard Drives
    various
    PSU
    pure power 11 400w cm
    Case
    Coolermaster
    Cooling
    cryorig m9i
  • Computer type
    PC/Desktop
    OS
    7x64
    CPU
    g5400
    Motherboard
    ga b365m ds3h
    Memory
    8gb ddr4 2400
    PSU
    xfx pro 450w
When you have a path with spaces or other special characters inside, you have to enclose it in double quotes. Program files is a common source of problems because of this, often resulting in errors saying "c:\program" missing or similar, just like in your post.
 

My Computer My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
RBCC

This what I use to check for CBS folder on desktop, if it exists, delete it, make new folder.

if exist %UserProfile%\Desktop\CBS (RD /s /q %UserProfile%\Desktop\CBS)
MD %UserProfile%\Desktop\CBS

/s Deletes a directory tree (the specified directory and all its subdirectories, including all files).
/q Specifies quiet mode. Does not prompt for confirmation when deleting a directory tree. The /q parameter works only if /s is also specified.

Good site for scripts and CMD
SS64.com
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
HP Desktop & Compaq Laptop
OS
Win 10 x64, Linux Lite, Win 7 x64, BlackArch, & Kali
Hard Drives
Samsung 850 Pro 256Gb,
Hitachi HDD 1Tb,
Crucial MX SSD 250Gb
Segate 3Tb USB 3.0 Ext. Backup HDD
Internet Speed
150Mbps dn, 20Mbps up
Antivirus
Avast Free, Malwarebytes Anti-Exploit & Anti-Ransomware
Browser
Firefox, Chrome, Opera, & VPN
if exist %UserProfile%\Desktop\CBS (RD /s /q %UserProfile%\Desktop\CBS)
MD %UserProfile%\Desktop\CBS

This has the very same bug as the OP's code. If the path has any space in it, it'll break with a strange error message about a file not being found, which can happen if the %UserProfile% environment variable has spaces (with a user name with spaces, rare but definitely possible). Like the OP, fix it by enclosing all paths in double quotes.
 

My Computer My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
Alejandro85

Thank you for the explanation.

I've been using that for years, never, ever had a problem.

However, I will change my code, being that it doesn't break anything.

Question: Why would someone place a space in the path?
Bad coding too?
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
HP Desktop & Compaq Laptop
OS
Win 10 x64, Linux Lite, Win 7 x64, BlackArch, & Kali
Hard Drives
Samsung 850 Pro 256Gb,
Hitachi HDD 1Tb,
Crucial MX SSD 250Gb
Segate 3Tb USB 3.0 Ext. Backup HDD
Internet Speed
150Mbps dn, 20Mbps up
Antivirus
Avast Free, Malwarebytes Anti-Exploit & Anti-Ransomware
Browser
Firefox, Chrome, Opera, & VPN
Alejandro85

Thank you for the explanation.

I've been using that for years, never, ever had a problem.

However, I will change my code, being that it doesn't break anything.

Question: Why would someone place a space in the path?
Bad coding too?
Snick
This comes from DOS era and 8x3 character limit. Most CMD are from that era.
You going to find a lot of space characters on windows path
C:\Program Files
C:\Windows\Downloaded Program Files
C:\Windows\Offline Web Pages
 

My Computers My Computers

System One System Two

  • Computer type
    PC/Desktop
    Computer Manufacturer/Model Number
    custom build
    OS
    Windows 7 HP 64
    CPU
    i5 6600K - 800MHz to 4200MHz
    Motherboard
    GA-Z170-HD3P
    Memory
    4+4G GSkill DDR4 3000
    Graphics Card(s)
    IG - Intel 530
    Monitor(s) Displays
    Samsung 226BW
    Screen Resolution
    1680x1050
    Hard Drives
    (1) -1 SM951 – 128GB M.2 AHCI PCIe SSD drive for Windows 7 and Lubuntu
    (2) -1 WD SATA 3 - 1T for Data
    (3) -1 WD SATA 3 - 1T for backup
    PSU
    Thermaltake 450W TR2 gold
    Keyboard
    Old and good Chicony mechanical keyboard
    Mouse
    Logitech mX performance - 9 buttons (had to disable some)
    Internet Speed
    500Mb/s
    Browser
    Firefox 64
    Other Info
    TinyWall firewall
  • Computer type
    Laptop
    System Manufacturer/Model Number
    Asus Q550LF
    OS
    Windows 7 Pro
    CPU
    i7-4500U 800MHz to 3.0GHz
    Motherboard
    Asus Q550LF
    Memory
    (4+4)G DDR3 1600
    Graphics Card(s)
    IG intel 4400 + NVIDIA GeForce GT 745M
    Sound Card
    Realtek
    Monitor(s) Displays
    LG Display LP156WF4-SPH1
    Screen Resolution
    1920 x 1080
    Hard Drives
    BX500 120G SSD for Windows and programs +
    1T HDD for data
    Internet Speed
    500 Mb/s
    Browser
    Firefox
    Other Info
    TinyWall firewall
Alejandro85

Thank you for the explanation.

I've been using that for years, never, ever had a problem.

However, I will change my code, being that it doesn't break anything.

Question: Why would someone place a space in the path?
Bad coding too?

File names with spaces are common place since they've been allowed. Windows itself contains quite a few of them built-in as Megahertz07 said. User documents names with spaces are even more common, and also some other programs use this. The mere fact that Windows allows them means that we must account for their possible presence.
I personally don't think it's a bad practice to use spaces, but many programs forget about them and such kind of bugs occur, unfortunately frequently.

Many programs simply work because they never happen to come by one path with spaces, but are otherwise incapable of handling them. It's not uncommon that some bugs remain undetected for a long time. Both Windows and Linux had bugs hidden for nearly 20 years, the heartbleed vulnerability remained for 2 years, spectre and its relatives were with us since the early Pentium days :p. My own code most likely has some bugs that nobody noticed and some day will bite someone.
Really, it's common to have such mistakes, and it's a good thing to spot them and fix if it's that easy. :-)
 

My Computer My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
HP Desktop & Compaq Laptop
OS
Win 10 x64, Linux Lite, Win 7 x64, BlackArch, & Kali
Hard Drives
Samsung 850 Pro 256Gb,
Hitachi HDD 1Tb,
Crucial MX SSD 250Gb
Segate 3Tb USB 3.0 Ext. Backup HDD
Internet Speed
150Mbps dn, 20Mbps up
Antivirus
Avast Free, Malwarebytes Anti-Exploit & Anti-Ransomware
Browser
Firefox, Chrome, Opera, & VPN
Back
Top