473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Set administrator privileges to WMI script

12
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.

Expand|Select|Wrap|Line Numbers
  1. my $WMI = Win32::OLE->GetObject("winmgmts:{impersonationLevel=impersonate,(security)}//127.0.0.1" ) 
  2. $WMI->Security_->Privileges->AddAsString ('SeDebugPrivilege', 1);
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.
Mar 13 '08 #1
5 4407
numberwhun
3,509 Expert Mod 2GB
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.

Expand|Select|Wrap|Line Numbers
  1. my $WMI = Win32::OLE->GetObject("winmgmts:{impersonationLevel=impersonate,(security)}//127.0.0.1" ) 
  2. $WMI->Security_->Privileges->AddAsString ('SeDebugPrivilege', 1);
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
Mar 14 '08 #2
You need to use the swbemlocator like so:

Expand|Select|Wrap|Line Numbers
  1. $locator = Win32::OLE->CreateObject("WbemScripting.SWbemLocator");
  2. $WMI = $locator->ConnectServer( $computer, "root/cimv2", $user, $pass);
Mar 14 '08 #3
idoha
12
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.
Mar 14 '08 #4
numberwhun
3,509 Expert Mod 2GB
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?
Mar 14 '08 #5
idoha
12
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.
Mar 15 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ted | last post by:
How do I grant all privileges for a schema that has a large number of existing tables, procedures, functions, etc to a newly created role, without having to issue a grant statement for each object...
3
by: ray well | last post by:
hi, are administrator rights needed when installing mdac ? are administrator rights needed when installing .net framework ? thanks, ray
0
by: Stefano Bonnin | last post by:
Hi, I'm a Postgis user, and I have a problem restoring data from 7.4 to 8.0..0beta2. I use the postgis_restore.pl script that comes with postgis distribution. I do the following for the dump:...
8
by: Dave | last post by:
I want to create a program that can only be run by a user with administrator privileges (ie in the BUILTIN/Administrators group - I think. Correct me if I'm wrong, I'm a bit hazy on users and...
5
by: Martijn Saly | last post by:
I'd like to test in my script, if it's going to be possible to enable priviliges. If I use this... netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect") ....it presents a...
1
by: srujan | last post by:
Hi, I need a script to provide administrative Privileges to install software from the network and revoke the privileges after installation of that software.I need this to install for the users...
3
by: Rahul B | last post by:
Hi, I want to grant only the connect, select, insert, update privileges on all the tables of a schema to a particular user/group Initially, i had revoked all the privileges from public. It...
8
by: =?Utf-8?B?TWFydGluIFNhY2hz?= | last post by:
I have been using MSCONFIG (XP Pro) for four years with no problem. I always use it in Administrator. Last night, when I attempted to go into selective startup mode, I got the following error...
5
by: nagar | last post by:
I'm using the Process.Start method to launch an application from C#. How can I launch the App as Administrator in Windows Vista? Thanks. Andrea
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.