supersonic Posted August 26, 2009 Share Posted August 26, 2009 (edited) Hi! Is it possible to run a specific (WMI) part of a script with different user rights? Here's my demo script: Global $strComputer = "." Global $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\default") MsgBox(0, "", _lReset("2f32cb5e-9d45-4ce9-9c85-7bee3cbcd771"), 0) Func _lReset($iStr = "") Local $objItem = $objWMIService.Get("VirtualSoftwarePackage.Id=""" & $iStr & """") Local $RetVal = 0 If @error <> 0 Then $RetVal = 1 Else $objItem.Reset() If @error <> 0 Then $RetVal = 2 Else ConsoleWrite("$objItem.Reset() --- " & $iStr & " --- " & $objItem.Name & @CRLF) EndIf EndIf Return $RetVal EndFunc With the help of WMI commands I am trying to control Symantec's SWV (fak SVS). This works pretty well so far (as an admin user), but when executing $objItem.Reset() the script has to switch from normal user rights to admin user rights. Is it possible to switch the user context for the WMI part? Any ideas? Greets, -supersonic. Edited August 26, 2009 by supersonic Link to comment Share on other sites More sharing options...
GEOSoft Posted August 26, 2009 Share Posted August 26, 2009 You will probably be okay with #RequireAdmin at the top of your script. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
supersonic Posted August 26, 2009 Author Share Posted August 26, 2009 You will probably be okay with #RequireAdmin at the top of your script.I am afraid, no... >_<Is it possible to initiate WMI services via DllCall()??? Link to comment Share on other sites More sharing options...
GEOSoft Posted August 26, 2009 Share Posted August 26, 2009 http://www.autoitscript.com/forum/index.php?showtopic=81880&view=findpost&p=587207 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted August 26, 2009 Share Posted August 26, 2009 In my experience with using it, the only way to get to WMI as another user was usually to run an entire other program as that user, and let it do the WMI related tasks. Remotely, yes you can run WMI queries as a different user, but locally, it won't work. At least, not with the same method, IIRC. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now