Quantcast
Channel: SAPIEN Forums
Viewing all articles
Browse latest Browse all 311

PowerShell Studio • Exception calling SetValue

$
0
0
Here are my details:
Product: PowerShell Studio 2024 (64 Bit)
Build: v5.8.237
OS: Windows 10.0.19045
PS Version(s): 5.1.19041.1

*** Please add details and screenshots as needed below. ***

I have this service script and it seems that ever since I updated to the above version I keep getting an error:

Code:

System.Management.Automation.MethodInvocationException: Exception calling "SetValue" with "4" argument(s): "The parameter is incorrect." ---> System.IO.IOException: The parameter is incorrect.   at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)   at Microsoft.Win32.RegistryKey.CreateSubKeyInternal(String subkey, RegistryKeyPermissionCheck permissionCheck, Object registrySecurityObj, RegistryOptions registryOptions)   at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey)   at Microsoft.Win32.Registry.SetValue(String keyName, String valueName, Object value, RegistryValueKind valueKind)   at CallSite.Target(Closure , CallSite , Type , String , String , String , RegistryValueKind )   --- End of inner exception stack trace ---   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at Invoke-MyService, <No file>: line 642
at <ScriptBlock>, <No file>: line 2

Here are the lines

Code:

639:  [microsoft.win32.registry]::SetValue("HKEY_USERS\$sid\Control Panel\Desktop", "ScreenSaveActive", "1", [Microsoft.Win32.RegistryValueKind]::String)640:[microsoft.win32.registry]::SetValue("HKEY_USERS\$sid\Control Panel\Desktop","ScreenSaverIsSecure","1",[Microsoft.Win32.RegistryValueKind]::String)641:[microsoft.win32.registry]::SetValue("HKEY_USERS\$sid\Control Panel\Desktop","ScreenSaveTimeOut","$SST",[Microsoft.Win32.RegistryValueKind]::String)642:643:

It says line 642, but none of those lines get set. Yet when I run the commands in powershell by themselves it works great. So there isn't a problem with the code.

Statistics: Posted by blackwbr — Mon Feb 05, 2024 12:36 pm — Replies 6 — Views 107



Viewing all articles
Browse latest Browse all 311

Trending Articles