BAT output


  1. Posts : 315
    Windows 10 Home Single Language 21H1
       #1

    BAT output


    Hey guys!

    I want to get a reg output file from a bat file
    I will run x.bat it will give me x.reg

    Everything seems to be ok. But i want double \\ character for path entry and it gives me one \ character
    and i dont want the last \ character too

    bat script and the outputs are here;

    C:\OKUL\SINIF\OGRENCI\x.bat i run that

    x.bat

    Code:
    CD /D "%~dp0"
    set x=%~dp0
    echo Windows Registry Editor Version 5.00>x.reg
    echo. >>x.reg
    echo [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\*SuckSystem]>>x.reg
    echo "Name"="destro">>x.reg
    echo "Path"="%x%">>x.reg
    echo "ChatState"=hex:02>>x.reg
    echo "MiniDash"=hex:00>>x.reg
    echo "OpponentList"=hex:01>>x.reg
    Reg Import "x.reg"
    x.reg i got that

    Code:
    Windows Registry Editor Version 5.00
     
    [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\SuckSystem]
    "Name"="destro"
    "Path"="C:\OKUL\SINIF\OGRENCI\"
    "ChatState"=hex:02
    "MiniDash"=hex:00
    "OpponentList"=hex:01
    result;

    "Path"="C:\OKUL\SINIF\OGRENCI" i am taking this entry

    "Path"="C:\\OKUL\\SINIF\\OGRENCI" i want this entry

    Can you help me to fix this?
      My Computer


  2. Posts : 12,417
    Win10 Version 21H2 Pro and Home, Win11 Pro
       #2

    MS-DOS and Windows use the single backslash \ in their path statements. I seldom see double backslashes so wonder what their use/need is. I do see the double forward slash // used with URLs.
      My Computers


  3. Posts : 870
    11 Home
       #3

    Code:
    @echo off
    setlocal enabledelayedexpansion
    set x=%~dp0
    if "!x:~-1!"=="\" set x=!x:~,-1!
    set x=%x:\=\\%
    echo "Path"="!x!">>x.reg
    pause
      My Computers


  4. Posts : 315
    Windows 10 Home Single Language 21H1
    Thread Starter
       #4

    hdmi said:
    Code:
    @echo off
    setlocal enabledelayedexpansion
    set x=%~dp0
    if "!x:~-1!"=="\" set x=!x:~,-1!
    set x=%x:\=\\%
    echo "Path"="!x!">>x.reg
    pause
    Thank you very much hdmi, it has fixed my problem.



    Berton said:
    MS-DOS and Windows use the single backslash \ in their path statements. I seldom see double backslashes so wonder what their use/need is. I do see the double forward slash // used with URLs.
    you need double \ to enter a path of an icon or executable file if you use .reg file
    you can see a long example of winaero's settings context menu tweak
    Add Settings Context Menu In Windows 10
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 05:43.
Find Us




Windows 10 Forums