1.

Solve : How to escape special characters on InputFile with Drag and Drop ??

Answer»

Hi   
The goal of this code is to drag and drop a file onto the script and it encodes or decodes it in Base64 with Certutil Command.
So my question is : "What can i do to escape special characters when a file to be encoded or DECODED have them ?"
Thank you !
Code: [Select]echo off
Set "file=%~1"
If "%file%"=="" GOTO:EOF
>nul find "-----BEGIN CERTIFICATE-----" "%file%" && (
 certutil -f -v -decode "%file%" "%file%"
) || (
 certutil -f -v -encode "%file%" "%file%"
)
EXITIn C++ I have had to escape the escape character such as \\. In BATCH you should also be able to do the same by a double escape using a batch escape character. The first escape is saying to escape the literal escape character. https://www.robvanderwoude.com/escapechars.phpI got a solution, so the problem is solved 
Code: [Select]echo off
Title Encode and Decode files into B64
setlocal enableextensions enabledelayedexpansion
set "COUNT=0"
set scr="%~f0"
set "cmd=!cmdcmdline:*%~f0=!"
set "ARGS=!cmd:~0,-1!"
set "args=!args:* =!"

for %%f in (!args!) do (
   set /a "count+=1"
   set infull[!count!]="%%~f"
)

for /l %%i in (1,1,!count!) do (
   Set "file=!infull[%%i]!"
)

If [!file!]==[] GOTO:EOF
echo !file! & pause

>nul 2>&1 find /I "-----BEGIN CERTIFICATE-----" !file! && (
certutil -f -v -decode !file! !file!
) || (
certutil -f -v -encode !file! !file!
)
pause
Exit



Discussion

No Comment Found