windows - Cannot read registry key when using SRVANY -


i working on script needs read , write value hklm registry hive. while works fine when running script, registry access denied when running same code service using srvany utility. service created using srvany runs under local system context belive should have full access hklm registry hive. when running code script, running under administrator account.

reg_key_path = "hklm\software\appname\serviceconfig" strfilename = objwshshell.regread(reg_key_path) 

the error above code

invalid root in registry key "hklm\software\appname\serviceconfig"

the trick use "c:\windows\sysnative\cscript.exe" launch cscript via srvany. full credit hans passant answer.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -