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

PsExec could not start powershell #13

Open
manav0619 opened this issue Nov 14, 2022 · 4 comments
Open

PsExec could not start powershell #13

manav0619 opened this issue Nov 14, 2022 · 4 comments

Comments

@manav0619
Copy link

manav0619 commented Nov 14, 2022

Hello,
I am running W11 22H2. I have been trying to fix my WindowsApps folder that I messed up permissions for and came across your script. However, it's not working for some reason on my PC. I keep getting the "PsExec could not start powershell…" error. I was wondering if you could assist me a bit. Any help will be truly appreciated.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\manav> cd J:\Users\manav\Downloads\PSTools
PS J:\Users\manav\Downloads\PSTools> .\psexec.exe -s -i powershell -ExecutionPolicy Bypass -File "J:\Users\manav\Downloads\WindowsAppsUnfukker-main\WindowsAppsUnfukker.ps1"

PsExec v2.4 - Execute processes remotely
Copyright (C) 2001-2022 Mark Russinovich
Sysinternals - www.sysinternals.com


PsExec could not start powershell on DESKTOP-99N6EMR:
The system cannot find the file specified.
@AgentRev
Copy link
Owner

It means Powershell cannot access the path to the script. In my experience, the usual culprit is network drives. I would say, try to move the script to a different drive.

@manav0619
Copy link
Author

@AgentRev Hey, thanks for responding. I don't actually have any network drives. Just two SSDs and two HDDs, all local. I have tried moving the script to different locations on every drive, but it's the exact same error every time.
If you'd like to see any log file or system information that might help you identify the issue, I'd be happy to provide it. I really have no idea what's going wrong.

@AgentRev
Copy link
Owner

AgentRev commented Nov 14, 2022

At that point, it's beyond my reach. You could use Process Monitor to investigate where is PsExec trying to look and why it's not resolving it. Other people have also recommended PAExec instead, maybe give that a try.

@manav0619
Copy link
Author

It wasn't PowerShell being unable to access the path to the script; it was rather PsExec being unable to access PowerShell.

I just added the full path to powershell.exe in the command, and it ended up working.

So, instead of

.\psexec.exe -s -i powershell -ExecutionPolicy Bypass -File "C:\WindowsAppsUnfukker-main\WindowsAppsUnfukker.ps1

I used

.\psexec.exe -s -i "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -File "C:\WindowsAppsUnfukker-main\WindowsAppsUnfukker.ps1

(I guess my environment variables are messed up as well? Because I had to add the System32 folder to "Path" under User Variables for takeown command to work when I was manually trying to fix the permissions earlier.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants