Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System Environment Variables do not applied if run program from Explorer directly in the sandbox. #1239

Open
koliu opened this issue Oct 2, 2021 · 2 comments
Labels
High priority To be done as soon as possible ToDo To be done

Comments

@koliu
Copy link

koliu commented Oct 2, 2021

Describe the bug

When I set some custom Windows system environment variables in a sandbox.
Run the program placed in the sandbox folder (%sandboxie%\%user%\box\drive\D\vscode\Code.exe) in two different ways, the Windows system environment variables are not the same.

  • [Expected] Run with command: "...\Sandboxie-Plus\Start.exe" /box:box "%sandboxie%\%user%\box\drive\D\vscode\Code.exe".
  • [Unexpected] Run the program directly through the Explorer. This will not apply the above variables.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new sandbox named box.
  2. Set up custom env vars:
    a. Run control through the sandbox right-click menu: Run -> Run Program
    b. Choose System -> Advanced system settings
    c. On the Advanced tab, click Environment Variables
    d. Click New to create a new environment variable with:
    - name: test
    - value: echo test...
  3. Set up VS Code
    a. Download VSCode
    b. Unzip it to the sandbox folder: [YOUR sandboxie PATH]\box\drive\D\vscode\
  4. Run VS Code with command:
    a. [Win + R] to display dialog.
    b. Enter: "C:\Program Files\Sandboxie-Plus\Start.exe" /box:box "[YOUR sandboxie PATH]\box\drive\D\vscode\Code.exe"
    c. [Ctrl+`] to display VS Code terminal.
    d. Click the v sign in the upper right corner of the terminal to show the dropdown list
    e. Click Commond Prompt on the dropdown list to launch cmd console
    f. Enter command: %test%
    C:\Users\User>%test%
    test...       
    
    C:\Users\User>
    
  5. Run VS Code with Explorer directly:
    a. [Win + E] to start Explorer.
    b. Go to the sandbox folder: [YOUR sandboxie PATH]\box\drive\D\vscode\
    c. Double click the Code.exe to start VS Code IDE in the box sandbox.
    d. Repeat the above steps 4-c to 4-e.
    e. Enter command: %test%
    C:\Users\User>%test%
    '%test%' is not recognized as an internal or external command, operable program or batch file.    
    
    C:\Users\User>
    

Note: Steps 4 and 5 are running the code.exe in the same sandboxie environment, but the applied system environment variables are not the same!

Expected behavior
Consistent system environment variables.

System details and installed software (please provide the following information):

  • Windows 10 Pro 21H1.
  • Sandboxie Plus 0.9.6.
  • Latest VS Code.
  • Comodo Personal Firewall 12.2.2.8012
@DavidXanatos DavidXanatos added the ToDo To be done label Oct 16, 2021
@DavidXanatos
Copy link
Member

this is kind of expected, the changes you do in the sandbox do not propagate to the real system, but when setting up the environment the real system values are used.
To make this work a new functionality would need to be added to check the sandboxed registry for added variables and add them.

@koliu
Copy link
Author

koliu commented Oct 17, 2021

To make this work a new functionality would need to be added to check the sandboxed registry for added variables and add them.

This seems to be a good functionality to solve the out-of-sync environment variables between the system and the sandbox, when one of them changes the env setting. And it may need to consider the problem of overwriting.

In addition, the main issue I posted is that different environment variables are imported in the same sandbox.
As far as I know, if the program is placed in the sandbox folder, there are two ways to start the program in the sandbox:

  • Run the program by the command in cmd: [Sandboxie-Plus path]\Start.exe \box:xxx [program]
  • Double-click to run the program in the Explorer

** Please note that the sandbox has its own environment variable settings (I have changed it), so it is different from the system environment variables.**

Both of the above methods start the program in the sandbox (managed by the sandbox) as expected. However, the former imported the environment variables of the sandbox as expected, while the latter imported the environment variables of the system, which was unexpected.

@DavidXanatos DavidXanatos added the High priority To be done as soon as possible label Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
High priority To be done as soon as possible ToDo To be done
Projects
None yet
Development

No branches or pull requests

3 participants