Execute Command As Administrator


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Execute Command As Administrator

Hybrid View

  1. #1
    Join Date
    Nov 2009
    Posts
    2

    Execute Command As Administrator

    Okay, so I have to execute a batch command on a restricted user's account, however the batch command will not work unless the process has Administrative Privileges.

    currently i call the batch command via
    Code:
    system("command here");
    I, as the programmer, know the Administrator user/password on the WinXP machine this is to be executed on.

    How can i execute this command/program as an administrator? I'm thinking about using the
    SetThreadToken() function (http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx) but I do not know how to construct the token object properly

    Thanks,
    Philly0494

  2. #2
    Join Date
    Dec 2003
    Posts
    3,366
    Make a shortcut to the program. Open this, and fool with the advance stuff; you can tell it to run under different credientails.

    Now, from the code:

    system("c:\whatever\...\shortcut.lnk");

    will run your shortcut which will handle the credentials for you easily.

  3. #3
    Join Date
    Nov 2009
    Posts
    2
    Quote Originally Posted by jonnin View Post
    Make a shortcut to the program. Open this, and fool with the advance stuff; you can tell it to run under different credientails.

    Now, from the code:

    system("c:\whatever\...\shortcut.lnk");

    will run your shortcut which will handle the credentials for you easily.
    Could the user then exploit this to either figure out the admin password or replace the program I made with another program that he/she wants to run as administrator in the office for non-work related purposes?

  4. #4
    Join Date
    Dec 2003
    Posts
    3,366
    I dont think so, depends on how good the person is. You should be able to lock down the shortcut file to execute only for the non-priveledged account via permisisons. I am not really sure how secure that actually would be though. It would aggravate a normal user, a skilled one may find a door here.

    I think that anyone who can hack the shortcut, if you lock it up, could probably also hack an executable with a hex editor to read off the password or change the destination of the command. System calls in a program are not exactly secure =)

    Edit: I was wrong, its been a while since I did this --- that shortcut feature has a menu for the user to say what account he runs the program as, then he has to enter the password, so it is no good for your application. Its for people you trust with your admin password only I guess.

    All that to say I am not sure how to construct your object. Maybe google to find an example of the object in use or something... sorry I can't help with that one.
    Last edited by jonnin; 11-14-2009 at 04:44 PM.

Similar Threads

  1. Select into variables using execute
    By Jim Anderson in forum Database
    Replies: 2
    Last Post: 07-01-2009, 04:39 PM
  2. How to execute a method of the class loaded
    By naveenkumarg1 in forum Java
    Replies: 1
    Last Post: 11-18-2005, 08:13 PM
  3. Replies: 1
    Last Post: 09-21-2005, 10:57 AM
  4. execute immediate
    By Ervin Rodriguez in forum Database
    Replies: 1
    Last Post: 10-03-2002, 03:55 PM
  5. execute immediate
    By Ervin Rodriguez in forum Database
    Replies: 3
    Last Post: 08-23-2002, 11:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center