Solved

Credentials and Launching Processes on Other Machines

Posted on 2004-08-31
12
232 Views
Last Modified: 2010-04-15
I've been researching for some time the methods available to run processes on other machines. WMI CreateProcess is one and the AT command scheduler is another and I have so far put those into practice with good results.

Sysinternals have wrapped it up nicely in their PSEXEC tool but I need to be able to do this programmatically and I don't know what API calls or os features they used to achieve remote execution.

Has anyone come across methods (other than WMI or AT) available for launching processes on other machines and I would be particularly interested in solutions which allow the passing of credentials so we're not just running under the "system" account.

thanks
0
Comment
Question by:plq
  • 5
  • 5
  • 2
12 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 11942536
PsExec basically uses the SCM API 'CreateService()' and 'StartService()' to install a service on the remote machine and execute arbitrary programs by connecting to that service which provicdes named pipes. See http://www.ntkernel.com/articles/psexec.shtml 

0
 
LVL 86

Expert Comment

by:jkr
ID: 11942552
Oh, addressing the 'credentials'  part - that is implicitly done by creating the service to run under a specific user account.
0
 
LVL 8

Author Comment

by:plq
ID: 11942651
Hi jkr,

Yes I'm just reading that article. Must admit I'm more than a bit disappointed that they actually make changes to the remote machine (adding a service), although presumably they add a service, run the program and then remove the server so there's no permanent damage. Still if the thing fails halfway through presumably the end user is left with this service installed and started on their machine at least until the next reboot.

I'm going to research this further. I'm also thinking of looking at RPC - is that a way to launch a program remotely ?
0
 
LVL 86

Expert Comment

by:jkr
ID: 11942813
>>I'm also thinking of looking at RPC - is that a way to launch a program remotely ?

Yes, but that also requires starting a server process on the remote machine that launches the program in question and provides means to communicate with that program.
0
 
LVL 86

Expert Comment

by:jkr
ID: 11942825
BTW, see 'RPCExec' (http://www.listsoft.com/programs/202/) - that app does it via RPC
0
 
LVL 8

Author Comment

by:plq
ID: 11943508
Just one more question. Is RPC able to remote call a windows API function (like createprocess) on the client, or can you only create activex objects ?

In my case the program in question will be resident server share

so I will be doing createprocess on

\\comptuername\share\myfile.exe <params>

The program is for systems management so no need for a user interface and indeed this particular one only writes a single file back to the share (its a null session share)
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 86

Expert Comment

by:jkr
ID: 11943875
No, using RPC, all you can do is provide a server that calls 'CreateProcess()' on your behalf, but you cannot call any APIs directly. Also, RPC and ActiveX are not really related.
0
 
LVL 8

Author Comment

by:plq
ID: 11946167
OK thanks jkr.
0
 

Expert Comment

by:gswitz
ID: 12433334
strComputer = "ServerName"
path="d:\test\temp"

Set objSwbemLocator = CreateObject("WbemScripting.SwbemLocator")
Set objSwbemService = objSwbemLocator.ConnectServer(strcomputer, "root\cimv2", "ServerName\test", "test")
Set objfolder = objSwbemService.Get("Cim_Directory.name='" & path & "'")
objFolder.delete
0
 
LVL 8

Author Comment

by:plq
ID: 12433348
Whats that ?
0
 

Expert Comment

by:gswitz
ID: 12433677
0
 
LVL 8

Author Comment

by:plq
ID: 12433767
Thanks, but jkr answered the question perfectly, and the question did request solutions other than WMI or AT, which I already knew about.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Statment to match two tables in c# 6 77
C: GetDiskFreeSpaceEx() for default drive 14 104
How to create project in Eclipse ? 1 193
gdb doesn't stop on breakpoint 2 45
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now