|
Answer» Hi, so I have created a batch file to replace each occurence of the SUBSTRING "sid" in a reg file with the usersid. The only problem is some of the DATA gets truncated. Consider this batch file:
@echo off ;Get sid from file set /p usersid= SETLOCAL DISABLEDELAYEDEXPANSION FOR /F %%L IN (sandboxie.reg) DO ( SET "line=%%L" SETLOCAL ENABLEDELAYEDEXPANSION ECHO !line:sid=%usersid%!>>out.reg ENDLOCAL ) ENDLOCAL
out.reg:
[HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\*\shell\sandbox] "Icon"="\"C:\\Program [HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\*\shell\sandbox\command] [HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\*\shell\sandbox\command] @="\"C:\\Program [HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder] [HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell] [HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell\sandbox] [HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell\sandbox] @="Run [HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell\sandbox] "Icon"="\"C:\\Program [HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell\sandbox\command] [HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell\sandbox\command] @="\"C:\\Program
sandboxie.reg:
[HKEY_USERS\sid_Classes\*\shell\sandbox\command] @="\"C:\\Program Files\\Sandboxie\\Start.exe\" /box:__ask__ \"%1\" %*"
[HKEY_USERS\sid_Classes\Folder]
[HKEY_USERS\sid_Classes\Folder\shell]
[HKEY_USERS\sid_Classes\Folder\shell\sandbox]
[HKEY_USERS\sid_Classes\Folder\shell\sandbox] @="Run &Sandboxed"
[HKEY_USERS\sid_Classes\Folder\shell\sandbox] "Icon"="\"C:\\Program Files\\Sandboxie\\Start.exe\""
[HKEY_USERS\sid_Classes\Folder\shell\sandbox\command]
[HKEY_USERS\sid_Classes\Folder\shell\sandbox\command] @="\"C:\\Program Files\\Sandboxie\\Start.exe\" /box:__ask__ Explorer.exe \"%1\""
As you can see, the string: @="\"C:\\Program Files\\Sandboxie\\Start.exe\" /box:__ask__ Explorer.exe \"%1\"" gets truncated to: @="\"C:\\Program in out.reg
How do I fix the script to get proper output?Same truncation will OCCUR on any line containing a space.
Space is one of the default delimiters in a For loop so as soon as the space after Program is encountered that's the end of the line.
Suggest you use For /f "tokens=*" .....etc so that the text line is TREATED as one and not delimited.
Welcome to the CH forums & hope this helps.Appreciate! That worked Thanks for coming back to REPORT your success..
|