I would guess that you might find the short names of some files (in case that feature is activated on your system).
You might test that by forcing the dir command to also display short filenames:
You have to escape the characters, that are not encapsulated within double quotes, which in the example should be everything colored red: powershell -command " Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorID | ForEach-Object { $_.PSObject.Properties | ForEach-Object { if ($_.Name -ne 'Ci...
The for/f loop uses the prompt command to store the Backspace character into the envronment variable DEL. The set/p command stores the backspace character into a file with the name defined by the second parameter of the :colorText function. The findstr command searches for any non empty line in that...
You got sth wrong with "%~0\..", so let's consider starting the batch file "crysis2.bat" from the current directory "c:\ABC\Bin32". Here the string "%~0\.." is expanded to "crysis2.bat\..". The string neither starts with a "\\", nor with a vomue designator (like for example "X:"). Therefore it is a ...
The reason why 'pushd "%~0\.."' works is pretty simple: Your batch file was successfully started from an initial location with the content of %0, so it must contain a path from the initial location to the batch file location. The 'pushd' command expects a path to a directory and doesn't expect any n...
What exactly are you looking for, when you write "i will find a detour to find a parent dir name"? Are you looking for the parent name of the current directory, or the name of your currently running batch file's directory, or sth else? I suspect you might look for sth like the following: @echo off s...
Though the output indeed depends on the filename used when calling the batch, the examples you have used shouldn't produce different results if being called in the same way. If you call the file with a filename only (encapsulated in doublequotes), then you should get this output: D:\Crysis 2\bin32\ ...
Without any sample data, we can only guess. The pipe exclusively works in binary mode and till now, i never saw it fail. Any encoding is done either by the command line interpreter, or by the programs on each end of the pipe. In my experience the most common error is that the program on the sink sid...
Usually when opening a console the cmd line is 'C:\Windows\System32\cmd.exe', while when double clicking a bat the cmd line is 'C:\WINDOWS\system32\cmd.exe /c "<path to batch fie>" ', which might result in different defaults beeing loaded. You might check the default values by: - creating a link to ...
You might use powershell within cmd.exe to change the last modified date of a file, so this might help you: @echo off setlocal enableExtensions disableDelayedExpansion set "sourceFile=%~f0" set "targetFile=stest.txt" powershell.exe -Command "$(Get-Item '%targetFile%').LastWriteTime=$(Get-Item '%sour...
There are three different timestamps you might want to change using powershell, so this might help you: @echo off setlocal enableExtensions disableDelayedExpansion set "sourceFile=%~f0" set "targetFile=stest.txt" :: Read timestamps into environment variables. for /f "tokens=1-3" %%a in ('powershell....
How can I get this above "export" code to work, I cannot see where the error is? My WinXP (not the newest version of WinXP) doesn't support the "/y"-switch. Once removed, it seem to work fine. What would I use in terms of code to "Import" or to restore the resultant backed up registry? The opposite...
At least under win10 notepad by default tries to guess the encoding (using whatever algorithm). In your and jebs example, notepad indeed guesses wrong and assumes UTF16-LE. But opening both explicitely in ANSI-encoding works fine. So i won't call that behaviour a bug, at least under win10, though un...