Re: Run an application from remote PC



Here is an example of how to use psexec.exe to spawn a process on another
computer.

program ps;
{$APPTYPE CONSOLE}

uses
SysUtils,
Windows;

var
cmd : string;
processInfo : TProcessInformation;
startUpInfo : TStartUpInfo;

begin //main program code
cmd := 'psexec \\xx.xx.xx.xx -d -i -p password -u userid
c:\utils\list.com c:\log';

startUpInfo.cb := SizeOf( startUpInfo );
FillChar( startUpInfo, 0, SizeOf( startUpInfo ) );
if not CreateProcess( Nil, pChar( cmd ),
Nil, Nil, False,0, Nil, Nil,startUpInfo, processInfo ) then
begin
WriteLn( 'Could not create process' );
Exit;
end;
WaitForSingleObject( processInfo.hProcess, INFINITE );
end.

If you get psexec.exe and run it without parameters, it will explain the
options for you.

-----Jon-----


"Jon Springs" <jsprings@xxxxxxxxxxxxxx> wrote in message
news:488f3ff7$1@xxxxxxxxxxxxxxxxxxxxxxxxx
This works like a champ. I use it every day.

http://technet.microsoft.com/en-us/sysinternals/0e18b180-9b7a-4c49-8120-c47c5a693683.aspx

-----Jon-----

"Dean Hill" <none@xxxxxxxx> wrote in message
news:488ecc3c$1@xxxxxxxxxxxxxxxxxxxxxxxxx
I got an exe on a server PC.
I would like to run this exe by ShellExecute from my machine but the
process
finally to be run as local process. Can I or how can I run this exe on
the
server?

You could perhaps shell to something like PSEXEC which is part of the Sys
Internals suite.

---
Dean



--- posted by geoForum on http://delphi.newswhat.com





.



Relevant Pages

  • Re: STARTUPINFO is not working ?
    ... it will just decrement the reference count on the kernel process object. ... STARTUPINFO functionality is not working. ... ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); ... CloseHandle(pi.hProcess); ...
    (microsoft.public.win32.programmer.kernel)
  • Re: calling a batch file within a thread?
    ... ProcessInfo: TProcessInformation; ... hProc: THandle; ... Win32Check(CreateProcess(nil, PChar(CmdLine), nil, nil, False, ... NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo)); ...
    (microsoft.public.win32.programmer.kernel)
  • REALbasic throws nilObjectException ? Why
    ... Below is the communication scheme: ... Below is the glue layer implementation for the same: ... nil, // Initializer ... sizeof(MyProperties)/sizeof(REALproperty), // sizeof properties ...
    (comp.lang.basic.realbasic)
  • Recompiling programs that have been started with ShellExecute or CreateProcess
    ... delete program "B"s exe file. ... StartupInfo: TStartupInfo; ... NIL, ... the reference count of a running process or thread? ...
    (comp.lang.pascal.delphi.misc)
  • Re: CreateProcess leaves child windows on rear
    ... active window if there is any. ... ZeroMemory(&ProcessInformation, sizeof(ProcessInformation)); ... ZeroMemory(&StartupInfo, sizeof(StartupInfo)); ...
    (microsoft.public.vc.mfc)