[SOLVED] Unable to rework working script due to name of folder and / or removal of sign -
Posted: 17 Mar 2023 12:58
This code works A-OK
i.e. it export settings of HotkeyP to to a file in form of
on my S volume holding various settings; e.g. to file like
But if I change that one crucial line to either
or
then I get no file in my Documents - but also no error. And that is, I reckon, because the scripts replaces the default
signs from filename with pauses - and as a side effect also unwantedly in the path. And as my folder of User is literally named
thus it gets transformed during execution to non existing
But then again- why do I not get an error or prompt about a need of creating new folder [i.e. >>YOUR USER NAME<< as only >>YOUR-USER-NAME<< exists]?
I have tried using double quotes vs. single ones, capitals vs. lower case, running the BAT from volume C instead from S - but the only thing that helps is just changing that line to e.g.
because changing it to
does not help
So what is happening here? How can I write a REG file to my Documents system folder with such simplistic code
but I am unable to do similar with the more complex code which works when output in it is changed to ordinary folders on volume C?
Code: Select all
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1-3 delims=/" %%A in ('powershell -command "Get-Date -Format 'yyyy/MM/dd'"') do (
set "year=%%A"
set "month=%%B"
set "day=%%C"
)
set "output_file=S:\Configs\HotkeyP\settings\%year% %month% %day%.reg"
set "output_file=!output_file:-= !"
set "output_file=!output_file: =!"
reg export "HKEY_CURRENT_USER\SOFTWARE\Petr Lastovicka\hotkey" "%output_file%"
endlocal
Code: Select all
YYYY MM DD.reg
Code: Select all
2023 03 17.reg
But if I change that one crucial line to either
Code: Select all
set "output_file=C:\Users\YOUR-USER-NAME\Documents\%year% %month% %day%.reg"
Code: Select all
set "output_file="%userprofile\Documents\%year% %month% %day%.reg""
Code: Select all
-
Code: Select all
YOUR-USER-NAME
Code: Select all
YOUR USER NAME
I have tried using double quotes vs. single ones, capitals vs. lower case, running the BAT from volume C instead from S - but the only thing that helps is just changing that line to e.g.
Code: Select all
set "output_file=C:\Temp\%year% %month% %day%.reg"
Code: Select all
set "output_file=C:\Users\Temp\%year% %month% %day%.reg"
So what is happening here? How can I write a REG file to my Documents system folder with such simplistic code
Code: Select all
reg export "HKEY_CURRENT_USER\SOFTWARE\Petr Lastovicka\hotkey" "C:\Users\YOUR-USER-NAME\Documents\HotkeyP settings.reg"