loxia01 / PSInternetConnectionSharing

This PowerShell Module provides simple functions to control Windows Internet Connection Sharing (ICS) from command line.
40 stars 8 forks source link

PS Crashes #3

Closed bryjonez closed 1 month ago

bryjonez commented 1 year ago

Hi @loxia01,

I need to share a VPN connection with a network adapter: FAH_VPN shared to VoipPhone

image

However when I issue the command:

Set-Ics -PublicConnectionName "FAH_VPN" -PrivateConnectionName "VoipPhone" -PassThru

Powershell crashes....

Any suggestions?

I can make the share manually andDisable-Icsworks after manually setting it up.

Thanks Bryan

loxia01 commented 1 year ago

Hi @loxia01,

I need to share a VPN connection with a network adapter: FAH_VPN shared to VoipPhone

image

However when I issue the command:

Set-Ics -PublicConnectionName "FAH_VPN" -PrivateConnectionName "VoipPhone" -PassThru

Powershell crashes....

Any suggestions?

I can make the share manually andDisable-Icsworks after manually setting it up.

Thanks Bryan

Thanks for submitting. Are you on Windows 10 or 11? Have not tested this module on Windows 11.

loxia01 commented 1 year ago

Edit: Updated the module to fix the bug. Probably the bug didn't cause your crash, but you can update the module and test.

I just discovered a small bug when doing some testing. It prevents Set-ICS to throw an error when the private network connection is disabled. Don't know if this caused the crash you reported, but to be sure you can just check if your network adapter is disabled before you run Set-ICS.

loxia01 commented 8 months ago

Thanks for your message.

Unfortunately I cannot reproduce your problem on my Win 10 machine. I know Microsoft did some sort of security update to ICS last month, but I am not sure if that is causing your crash.

Regards

23 nov. 2023 02:44 av @.***:

Probably related: https://user-images.githubusercontent.com/99139463/285077846-544a73ea-f3f5-4cde-9c16-1403d551fb10.png

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at IDispatchInvoke(IntPtr , Int32 , INVOKEKIND , DISPPARAMS& , Variant& , ExcepInfo& , UInt32& ) at System.Management.Automation.ComInterop.UnsafeMethods.IDispatchInvoke(IntPtr dispatchPointer, Int32 memberDispId, INVOKEKIND flags, DISPPARAMS& dispParams, Variant& result, ExcepInfo& excepInfo, UInt32& argErr) at CallSite.Target(Closure , CallSite , ComObject , Int32 ) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at System.Management.Automation.Interpreter.DynamicInstruction3.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.PSScriptCmdlet.RunClause(Action1 clause, Object dollarUnderbar, Object inputToProcess) at System.Management.Automation.PSScriptCmdlet.DoProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() at System.Management.Automation.CommandProcessorBase.DoExecute() at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input) at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext) at System.Management.Automation.Interpreter.ActionCallInstruction6.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.DlrScriptCommandProcessor.RunClause(Action1 clause, Object dollarUnderbar, Object inputToProcess) at System.Management.Automation.DlrScriptCommandProcessor.Complete() at System.Management.Automation.CommandProcessorBase.DoComplete() at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(CommandProcessorBase commandRequestingUpstreamCommandsToStop) at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input) at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper() at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc() at System.Management.Automation.Runspaces.PipelineThread.WorkerProc() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()[process exited with code 3221225477]

Disable-Ics correctly removes the checkbox and the selected home connection, and Set-Ics leaves the checkbox but does not select the connection; it can be activated manually. https://user-images.githubusercontent.com/99139463/285078572-16c28f62-9809-47c2-9cef-c101b87db65d.png

OS Windows 10 22H2 19045.3570

— Reply to this email directly, > view it on GitHub https://github.com/loxia01/PSInternetConnectionSharing/issues/3#issuecomment-1823728906> , or > unsubscribe https://github.com/notifications/unsubscribe-auth/AIW4BZOTVATMDXUMKC6QFT3YF2S7LAVCNFSM6AAAAAAYPMYEQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRTG4ZDQOJQGY> . You are receiving this because you were mentioned.> Message ID: > <loxia01/PSInternetConnectionSharing/issues/3/1823728906> @> github> .> com>

opzch commented 1 month ago

I know that's off-topic here, but maybe this can be helpful for someone facing these issues: Something that's not immediately obvious that, instead of relying on Windows sharing methods, you can just install a proxy app on the main machine and set other devices to connect through its' port (if they support it, of course). Almost any application should be sufficient to route through your current connection, but in some cases if you also need to connect through other (Internet) proxies, you might consider installing a proxy manager like v2RayN or similar that supports multiple protocols. Far more reliable than this.