You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If calling privacy-script.bat from another script which has setlocal EnableDelayedExpansion, many powershell code items failed to run.
OS
Reproduction steps
Create a script that call privact-script.bat as below:
@echo off & setlocal EnableDelayedExpansion
call privact-script.bat
Scripts
Screenshots
Additional information
It can be fixed by adding "setlocal DisableDelayedExpansion" at the beginning of the privact-script.bat, (also possibly "EnableExtensions" for user convenience), so it would be:
@echo off & setlocal EnableExtensions DisableDelayedExpansion
The text was updated successfully, but these errors were encountered:
However, I think it is a good practice to manage the environment in the script privacy.sexy to make it as robust and independent as possible. The script itself should handle this without requiring users to know about the internal workings and requirements. So I will add this.
I believe we should also add endlocal at the end of the script to ensure this script does not interfere with callers environment.
Out-of-topic: pause and exit /b 0 would probably be intrusive as well. We could add ability to disable those lines with a flag, but this we should discuss in another github issue as I'd consider this a feature rather than a bug fix.
This commit ensures the script functions as expected, even when invoked
from unexpected environments.
Using `setlocal` initializes a distinct environment for privacy.sexy.
It's strategically placed after the admin privilege check to avoid
unnecessary setup in case of a relaunch. The script concludes with
`endlocal` right before the exit, maintaining a clean environment
throughout its execution and ensuring no unintentional global
environment modifications.
Changes:
- Enhance script's environment robustness.
- Add descriptive comments for script start/end sequences.
Description
If calling
privacy-script.bat
from another script which hassetlocal EnableDelayedExpansion
, many powershell code items failed to run.OS
Reproduction steps
Create a script that call privact-script.bat as below:
Scripts
Screenshots
Additional information
It can be fixed by adding "setlocal DisableDelayedExpansion" at the beginning of the privact-script.bat, (also possibly "EnableExtensions" for user convenience), so it would be:
@echo off & setlocal EnableExtensions DisableDelayedExpansion
The text was updated successfully, but these errors were encountered: