Joly0 / Run-in-Sandbox

Run PS1, VBS, EXE, MSI in Windows Sandbox very quickly just from a right-click
17 stars 1 forks source link

Run in sandbox doesn't run apps/scripts #6

Open ZFranz opened 1 month ago

ZFranz commented 1 month ago

When clicking the run ps1/exe/msi/intunewin in sandbox it automatically open the sandbox, but does nothing. There are cases where I see people getting a prompt for which command they want to run, I don't even get that, the sandbox window open instantly but then nothing happen inside, I can only see a mapped folder that links to where I launched the sandbox.

Joly0 commented 1 month ago

Hey, could you maybe add some screenshots to your issue showing whats wrong :)

Joly0 commented 3 weeks ago

Hey @ZFranz without any further information i am going to close this issue by the end of the week. I cannot replicate this.

ZFranz commented 3 weeks ago

Here is the screen capture, I had to upload outside since it was bigger than 10MB, inside the intunewin file there are the msi installer and also a powershell script to install it, but after opening it in sandbox, I'm not prompted the parameter window, nothing happens. https://we.tl/t-gCu1hJZ9uw

Joly0 commented 3 weeks ago

Hey @ZFranz thanks for the video. I see the problem now. I just pushed a big update. Could you please do me a favor and download the project new, uninstall it by running the command "Remove_Structure.ps1 -DeepClean" and then install it new by running "Add_Structure.ps1". Then check if this registry key exists "Computer\HKEY_CLASSES_ROOT\SystemFileAssociations.intunewin" and what subkeys exist.

Here the "Command" subkey is important and should include: "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -NoProfile -ExecutionPolicy Unrestricted -sta -File C:\ProgramData\Run_in_Sandbox\RunInSandbox.ps1 -Type Intunewin -ScriptPath "%V""

Joly0 commented 3 weeks ago

Also, could you please provide some information about your system? OS version and buildnumber might be helpful here :)

ZFranz commented 3 weeks ago

Reinstalled the new version as per instructions, looked for the key and it exists, but after trying to run an intunewin file, still nothing. I've also tried to run the MSI file alone, also nothing.

I'm running windows 11 enterprise build 22631.3880

Joly0 commented 3 weeks ago

Hm, unfortunately, Run-in-Sandbox has basically 0 logging, so its quite difficult for me to analyse this problem, as i cant replicate it at all. I will get a test build ready for you in the next few days to test with some logging and some adjustments to pin down this issue.

I will ping you in this issue once i am done with instructions on how to download and install it.

Joly0 commented 1 week ago

Hey @ZFranz i have found a rather simple solution to get some simple logging which might help identify the issue while i try to implement proper logging. Please open your registry editor and go to this path: Computer\HKEY_CLASSES_ROOT\SystemFileAssociations\.intunewin\Shell\Run Intunewin in Sandbox\Command then replace the value of the standard key with this: C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -WindowStyle Hidden -NoProfile -ExecutionPolicy Unrestricted -sta -File C:\\ProgramData\\Run_in_Sandbox\\RunInSandbox.ps1 -Type Intunewin -ScriptPath "%V" > "C:\\Windows\\Temp\\RunInSandbox.log" 2> "C:\\Windows\\Temp\\RunInSandbox_error.log" The next time you run an intunewin file, there should be two files created in your C:\Windows\Temp folder called RunInSandbox.log and RunInSandbox_error.log, the first one being the default output, the second being the error output.

Please try to run any intunewin file and then post both these files here.

Joly0 commented 1 day ago

Hey @ZFranz have you had time to look i to my previous post?

ZFranz commented 1 day ago

After changing the registry key, run intunewin in sandbox doesn't work anymore and there aren't logs. now I just share the entire folder and test the powershell comand

Joly0 commented 1 day ago

Hey @ZFranz sorry, my bad. Please try using this command for the registry key, this should work:

C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -WindowStyle Hidden -NoProfile -ExecutionPolicy Unrestricted -sta -Command "& {C:\\ProgramData\\Run_in_Sandbox\\RunInSandbox.ps1 -Type Intunewin -ScriptPath '%V'} > 'C:\\Windows\\Temp\\RunInSandbox.log' 2> 'C:\\Windows\\Temp\\RunInSandbox_error.log'"
ZFranz commented 1 day ago

Here are the logs

RunInSandbox.log RunInSandbox_error.log

Joly0 commented 22 hours ago

Ok, i think i see the problem now. I´ll make a fix and will push it tomorrow for you to test :)

Joly0 commented 1 hour ago

@ZFranz Could you do me a favour and run this powershell command and tell me what its outputting please: $ExecutionContext.SessionState.LanguageMode