Set administrator privileges to WMI script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • idoha
    New Member
    • Aug 2007
    • 12

    Set administrator privileges to WMI script

    Hi,

    I am trying to write a script that kills processes that generated by the OS on a localhost. The problem is that this script must be run under a user with administrator privileges, otheriwse the script wont be able to kill the processes.

    Generally speaking, this script doesn't suppose to run under administrator but under a standard user privileges.

    I am using the following commands in order to open the WMI connection:
    Again, the WMI need to be executed locally and not remotely.

    [CODE=perl]my $WMI = Win32::OLE->GetObject("win mgmts:{imperson ationLevel=impe rsonate,(securi ty)}//127.0.0.1" )
    $WMI->Security_->Privileges->AddAsString ('SeDebugPrivil ege', 1);[/CODE]

    Is there a way to set the script to connect to WMI using administrator privileges? (assuming, of course, that I have administrator credentials).

    Thanks,

    Ido.
    Last edited by eWish; Mar 14 '08, 01:40 AM. Reason: Please use code tags when posting code
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by idoha
    Hi,

    I am trying to write a script that kills processes that generated by the OS on a localhost. The problem is that this script must be run under a user with administrator privileges, otheriwse the script wont be able to kill the processes.

    Generally speaking, this script doesn't suppose to run under administrator but under a standard user privileges.

    I am using the following commands in order to open the WMI connection:
    Again, the WMI need to be executed locally and not remotely.

    [CODE=perl]my $WMI = Win32::OLE->GetObject("win mgmts:{imperson ationLevel=impe rsonate,(securi ty)}//127.0.0.1" )
    $WMI->Security_->Privileges->AddAsString ('SeDebugPrivil ege', 1);[/CODE]

    Is there a way to set the script to connect to WMI using administrator privileges? (assuming, of course, that I have administrator credentials).

    Thanks,

    Ido.
    To begin with, what is "WMI"? I haven't heard of that.

    Doing things with Administrative privilage, especially remotely, is a definite NO NO. You will find that many places that set up machines for remote access, have it set to the administrator cannot log in remotely. This prevents questionable parties from doing so.

    Regards,

    Jeff

    Comment

    • seltzerb
      New Member
      • Mar 2008
      • 2

      #3
      You need to use the swbemlocator like so:

      [CODE=Perl]$locator = Win32::OLE->CreateObject(" WbemScripting.S WbemLocator");
      $WMI = $locator->ConnectServe r( $computer, "root/cimv2", $user, $pass);[/CODE]

      Comment

      • idoha
        New Member
        • Aug 2007
        • 12

        #4
        Hi,

        I am familier with the "connect server" function you have suggested.
        The only problem is that this is useful in order to run WMI on remote machines, while I need to run in on a local machine.
        I tried to use the "connect server" to connect to localhost but it refused, saying that connection to localhosts are not permitted.

        Any other options?

        Thanks,

        Ido.

        Comment

        • numberwhun
          Recognized Expert Moderator Specialist
          • May 2007
          • 3467

          #5
          Originally posted by idoha
          Hi,

          I am familier with the "connect server" function you have suggested.
          The only problem is that this is useful in order to run WMI on remote machines, while I need to run in on a local machine.
          I tried to use the "connect server" to connect to localhost but it refused, saying that connection to localhosts are not permitted.

          Any other options?

          Thanks,

          Ido.
          If you are ON the machine that it will be running on, then why do you need to connect to it? Shouldn't you just have to run the command(s) you need?

          Again, what is WMI?

          Comment

          • idoha
            New Member
            • Aug 2007
            • 12

            #6
            Hi,

            WMI stands for Windows Management Instrumentation . This is a set of extenstions by which you can retrieve information about the OS and manage its components like processes, services, memory, cpu usage etc..

            My mail goal is to kill processes created by the OS. WMI is just one option to do that. Currently, all options including WMI are failing to terminate processes because administrator priviliges are required to kill those processes.

            Since I intend to run the script on a local computer under a user which is not an administrator then I need to figure out a way to set the WMI command administrative privileges.

            Thanks,
            Ido.

            Comment

            Working...