-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Issue: gsudo: "Error: Invalid option: -noninteractive". The gsudo scriptblocks also fail. #305
Comments
Hi @fmotion1!
Rarely, I guess.. You are calling If that were the problem, calling
Could you please do Unrelated: the |
I'm invoking the script from within PowerShell Version: 7.3.7 PSEdition: Core
It shouldn't (isn't) running non-interactively at all. The script prompts the user several times for input and depends on that input to function. I don't have a This is interesting though: Even without any code in the scriptblock it's still erroring out:
If I run my script, I get the following:
If this helps, here's the code: Clear-Host
$PingResult = & ping 127.0.0.1
$PingResult[2] -match 'TTL=([\d]+)'
$CurrentTTL = $Matches[1]
Invoke-SpectrePrintMarkup -Message "--------------------------------------------------------`n"
Invoke-SpectrePrintMarkup -Message "[grey66]Current TTL Value is[/] [white]$CurrentTTL[/]`n"
Invoke-SpectrePrintMarkup -Message "--------------------------------------------------------`n"
Invoke-SpectrePrintMarkup -Message "[grey66]Windows 10 Default value for DefaultTTL is[/] [white]128[/]"
Invoke-SpectrePrintMarkup -Message "[grey66]Reccommended tweaked values are in the range of [/][white]55-70[/]`n"
[System.String]$TTLSelection = Invoke-SpectreTextPrompt -Prompt "[#00d787]Specify your desired DefaultTTL:[/]"
$TTLSelectionInt = $TTLSelection -as [int]
while(($TTLSelectionInt -lt 55) -or ($TTLSelectionInt -gt 128)){
Write-Error "TTL Value is outside of the reccommended range. Please enter a different value.`n"
[System.String]$TTLSelection = Invoke-SpectreTextPrompt -Prompt "[#00d787]Specify your desired DefaultTTL:[/]"
$TTLSelectionInt = $TTLSelection -as [int]
}
if($TTLSelectionInt -eq 128){
$Prompt = "Are you sure you want to reset [WHITE]DefaultTTL[/] to default? ($TTLSelectionInt)"
$Success = "`nSetting [white]DefaultTTL[/] to [white]$TTLSelectionInt[/] now.`n"
$Result = Invoke-SpectreTextPromptConfirm -Prompt $Prompt -ConfirmSuccess $Success
if($Result -ne "Y"){
exit
}
gsudo --debug { netsh int ipv4 set glob defaultcurhoplimit=128 >NUL }
gsudo --debug { netsh int ipv6 set glob defaultcurhoplimit=128 >NUL }
gsudo --debug { reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters" /v DisabledComponents /f }
} else {
$Prompt = "Are you sure you want to set [WHITE]DefaultTTL[/] to $TTLSelectionInt`?"
$Success = "`nSetting [WHITE]DefaultTTL[/] to [white]$TTLSelectionInt[/] now.`n"
$Result = Invoke-SpectreTextPromptConfirm -Prompt $Prompt -ConfirmSuccess $Success
if($Result -ne "Y"){
exit
}
gsudo --debug { netsh int ipv4 set glob defaultcurhoplimit=$($args[0]) >NUL } -args $TTLSelectionInt
gsudo --debug { netsh int ipv6 set glob defaultcurhoplimit=$($args[0]) >NUL } -args $TTLSelectionInt
gsudo --debug { reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters" /v DisabledComponents /t REG_DWORD /d 32 /f }
}
Invoke-SpectrePrintMarkup -Message "`n[white]DefaultTTL[/] has been set to [white]$TTLSelectionInt[/]`n"
read-host "You may close this window now or press any key to exit." Even if I just do this:
I have no idea what's going on. In the meantime, I've switched to another elevation technique. Hopefully this gets sorted because I really love the idea of Appreciate any help. Let me know if there is any more information I can give you. |
OK! I've made some progress! I've successfully got it to work outside VSCode if I run the script directly. Furthermore, I also replaced all But running within VSCode still produces the error. I know positively that VSCode does Automatic script injection. So I was thinking the If I run
But I checked that script and there is no Is there any way you can test/troubleshoot this on your end? I've attached the shell integration script to this post. |
Just saw the commit... Awesome! I hope it makes it into release soon. Just some further info - I can actually get the script to work in VSCode if I run the script "In a new terminal" (It's a feature in the PowerShell Pro Tools VSCode extension). Image for reference: This is definitely leading me to believe that the integrated terminal is spawning with the Either way, I hope the latest commit works! |
The parameter binding on native calls from PowerShell have some special rules, like: if a scriptblock appears, use a special Do you still get the error in the interactive terminal ? can you try Here is a potential fix for the issue: https://github.com/gerardog/gsudo/releases/tag/v2.4.1-fixnoninteractive |
Issue Description
I have a Powershell 7 script that modifies the registry and sets some commands with
netsh
. Here's the code:When I run the code, all works fine until the
gsudo
lines:Once these lines are processed, the console spits out three identical lines:
Context:
One thought I had is that
gsudo.exe
andgsudo
are in a separate folder (in my PATH) than the actual module files. Could this cause trouble?Any help at all would be greatly appreciated!
The text was updated successfully, but these errors were encountered: