even something as simple as this stopped working:
Code: Select all
writefile("%temp%\test.tmp","this is a test")Code: Select all
writefile("%temp%\test.tmp","this is a test")Code: Select all
OpenWith("""%programfiles%\winrar\winrar.exe"" x -ad -- <items>", "m");Indeed, I start to regret it.TheQwerty wrote:So now how do we use an environment variable in OpenWith and pass additional arguments?All this work to help the morons who create folders named the same as their environment variables has rendered a lot of my scripts and catalog useless in v8.50.Code: Select all
OpenWith("""%programfiles%\winrar\winrar.exe"" x -ad -- <items>", "m");
Code: Select all
TCHAR path[MAX_PATH+1];
_tcscpy_s(path, _T("\"D:\\Downloads\\%username%\\test.exe\" -n"));
TCHAR pathCopy[MAX_PATH+1];
_tcscpy_s(pathCopy, path); //Copy just in case.
PathRemoveArgs(path);
TCHAR *args = _tcsninc(pathCopy, _tcslen(path)); //Store args.
PathUnquoteSpaces(path);
if (! PathFileExists(path)) { //Try as is.
if (! PathResolve(path, NULL, PRF_VERIFYEXISTS)) { //Try as resolved relative or unqualified.
DoEnvironmentSubst(path, MAX_PATH);
if (! PathFileExists(path)) { //Try with expanded env. vars.
if (! PathResolve(path, NULL, PRF_VERIFYEXISTS)) { //Try with expanded env. vars and resolved relative or unqualified.
_tprintf(pathCopy); //File not found use starting value.
return 0;
}
}
}
}
PathQuoteSpaces(path);
_tcscat_s(path, MAX_PATH+1, args); //Restore the args.
_tprintf(path);
return 1;Extracting the path and checking for existence is a possibility but it would indeed slow down the whole thing too much. I will rather try to solve it on a purely syntactical level.TheQwerty wrote:Clearly I have no idea how you're currently checking the paths and I'm a bit of a noob to win32 programming with no VB experience but with a bit of playing in C++ would something like this work:It's not a pretty solution and probably not that efficient, but I'm sure you come up with something better.Code: Select all
TCHAR path[MAX_PATH+1]; _tcscpy_s(path, _T("\"D:\\Downloads\\%username%\\test.exe\" -n")); TCHAR pathCopy[MAX_PATH+1]; _tcscpy_s(pathCopy, path); //Copy just in case. PathRemoveArgs(path); TCHAR *args = _tcsninc(pathCopy, _tcslen(path)); //Store args. PathUnquoteSpaces(path); if (! PathFileExists(path)) { //Try as is. if (! PathResolve(path, NULL, PRF_VERIFYEXISTS)) { //Try as resolved relative or unqualified. DoEnvironmentSubst(path, MAX_PATH); if (! PathFileExists(path)) { //Try with expanded env. vars. if (! PathResolve(path, NULL, PRF_VERIFYEXISTS)) { //Try with expanded env. vars and resolved relative or unqualified. _tprintf(pathCopy); //File not found use starting value. return 0; } } } } PathQuoteSpaces(path); _tcscat_s(path, MAX_PATH+1, args); //Restore the args. _tprintf(path); return 1;
PS: The checking for existence method would also fail when new files are to be created: they do not exist, yet there path is perfectly alright.admin wrote:Extracting the path and checking for existence is a possibility but it would indeed slow down the whole thing too much. I will rather try to solve it on a purely syntactical level.
Indeed, but I wasn't aiming to provide a way to further this idiocy of creating items with "%...%" names, I just want my catalog and scripts to work correctly!admin wrote:PS: The checking for existence method would also fail when new files are to be created: they do not exist, yet there path is perfectly alright.admin wrote:Extracting the path and checking for existence is a possibility but it would indeed slow down the whole thing too much. I will rather try to solve it on a purely syntactical level.