![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | HowTo: Run a Command (.exe or .cmd) on a Remote Machine I appologize if this has been asked before, but I couldnt find any reference. Goal: ----- Basically I just want to run an App that resides in C:\windows\system32 of the remote machine. I normally just use psexec \\server App.exe Is there a more powershellish way to do this? |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: HowTo: Run a Command (.exe or .cmd) on a Remote Machine The PowerShellish way will be available in a future version of PowerShell which will including remoting features. Stay tuned. -- Narayanan Lakshmanan [MSFT] Windows PowerShell Development Microsoft Corporation This posting is provided "AS IS" with no warranties, and confers no rights. "Brandon Shell" <tshell.mask@gmail.com> wrote in message news:%235RDwBq1GHA.772@TK2MSFTNGP05.phx.gbl... >I appologize if this has been asked before, but I couldnt find any >reference. > > Goal: > ----- > Basically I just want to run an App that resides in C:\windows\system32 of > the remote machine. I normally just use psexec \\server App.exe > Is there a more powershellish way to do this? > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: HowTo: Run a Command (.exe or .cmd) on a Remote Machine Brandon Shell wrote: > I appologize if this has been asked before, but I couldnt find any > reference. > > Goal: > ----- > Basically I just want to run an App that resides in C:\windows\system32 of > the remote machine. I normally just use psexec \\server App.exe > Is there a more powershellish way to do this? Take a look at the ps tools from winternals - these may help -- Thomas Lee DoctorDns@gmail.com |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: HowTo: Run a Command (.exe or .cmd) on a Remote Machine You can use WMI MowPS>(new-object management.ManagementClass('\\computer\root\cimv2:win32_process')).InvokeMethod('Create','calc.exe' ) 0 Note that calc is just an test example, it is not interactive lanched remove Sample Script : http://mow001.blogspot.com/2006/03/m...on-update.html # win32_process Create-Method Sample Script # Created by Get-WmiMethodHelp (v3) # /\/\o\/\/ 2006 # Fill InParams values before Executing # InParams that are Remarked (#) are Optional $Class = "win32_process" $Method = "Create" $MP = new-object system.management.ManagementPath $MP.Server = "." $MP.NamespacePath = "root\cimv2" $MP.ClassName = $Class $MC = new-object system.management.ManagementClass($MP) $InParams = $mc.GetMethodParameters($Method) $InParams["CommandLine"] = [string] $InParams["CurrentDirectory"] = [string] $InParams["ProcessStartupInformation"] = [object:Win32_ProcessStartup] "Calling win32_process : Create with Parameters :" $inparams.get_properties() | select name,Value $R = $mc.InvokeMethod($Method, $inParams, $Null) "Result : " $R "Thomas Lee [MVP]" wrote: > Brandon Shell wrote: > > I appologize if this has been asked before, but I couldnt find any > > reference. > > > > Goal: > > ----- > > Basically I just want to run an App that resides in C:\windows\system32 of > > the remote machine. I normally just use psexec \\server App.exe > > Is there a more powershellish way to do this? > > Take a look at the ps tools from winternals - these may help > > -- > Thomas Lee > DoctorDns@gmail.com > |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: HowTo: Run a Command (.exe or .cmd) on a Remote Machine What kind of return should I expect? Does it just start the app and hope for the best or does it wait for the app to close? "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message news:9EA2014C-9C96-4950-A2C6-67020CE0416B@microsoft.com... > You can use WMI > > MowPS>(new-object > management.ManagementClass('\\computer\root\cimv2:win32_process')).InvokeMethod('Create','calc.exe' > ) > 0 > > Note that calc is just an test example, it is not interactive lanched > remove > > Sample Script : > http://mow001.blogspot.com/2006/03/m...on-update.html > > # win32_process Create-Method Sample Script > # Created by Get-WmiMethodHelp (v3) > # /\/\o\/\/ 2006 > # Fill InParams values before Executing > # InParams that are Remarked (#) are Optional > > > $Class = "win32_process" > $Method = "Create" > $MP = new-object system.management.ManagementPath > $MP.Server = "." > $MP.NamespacePath = "root\cimv2" > $MP.ClassName = $Class > > > $MC = new-object system.management.ManagementClass($MP) > $InParams = $mc.GetMethodParameters($Method) > > > $InParams["CommandLine"] = [string] > $InParams["CurrentDirectory"] = [string] > $InParams["ProcessStartupInformation"] = [object:Win32_ProcessStartup] > > > "Calling win32_process : Create with Parameters :" > $inparams.get_properties() | select name,Value > > > $R = $mc.InvokeMethod($Method, $inParams, $Null) > "Result : " > $R > > > "Thomas Lee [MVP]" wrote: > >> Brandon Shell wrote: >> > I appologize if this has been asked before, but I couldnt find any >> > reference. >> > >> > Goal: >> > ----- >> > Basically I just want to run an App that resides in C:\windows\system32 >> > of >> > the remote machine. I normally just use psexec \\server App.exe >> > Is there a more powershellish way to do this? >> >> Take a look at the ps tools from winternals - these may help >> >> -- >> Thomas Lee >> DoctorDns@gmail.com >> |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: HowTo: Run a Command (.exe or .cmd) on a Remote Machine The meaning of the return values is documented in MSDN: http://msdn.microsoft.com/library/en...32_process.asp The naming convention is a bit strange for methods of classes , but you can find the base documentation for any WMI class by using a URL of the form http://msdn.microsoft.com/library/en-us/wmisdk/wmi/<WMI-Class-Name>.asp This always has breakouts for the methods such as Create at the bottom. "Brandon Shell" <tshell.mask@gmail.com> wrote in message news:%23UaFUyy1GHA.4908@TK2MSFTNGP02.phx.gbl... > What kind of return should I expect? Does it just start the app and hope > for the best or does it wait for the app to close? > > > "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message > news:9EA2014C-9C96-4950-A2C6-67020CE0416B@microsoft.com... >> You can use WMI >> >> MowPS>(new-object >> management.ManagementClass('\\computer\root\cimv2:win32_process')).InvokeMethod('Create','calc.exe' >> ) >> 0 >> >> Note that calc is just an test example, it is not interactive lanched >> remove >> >> Sample Script : >> http://mow001.blogspot.com/2006/03/m...on-update.html >> >> # win32_process Create-Method Sample Script >> # Created by Get-WmiMethodHelp (v3) >> # /\/\o\/\/ 2006 >> # Fill InParams values before Executing >> # InParams that are Remarked (#) are Optional >> >> >> $Class = "win32_process" >> $Method = "Create" >> $MP = new-object system.management.ManagementPath >> $MP.Server = "." >> $MP.NamespacePath = "root\cimv2" >> $MP.ClassName = $Class >> >> >> $MC = new-object system.management.ManagementClass($MP) >> $InParams = $mc.GetMethodParameters($Method) >> >> >> $InParams["CommandLine"] = [string] >> $InParams["CurrentDirectory"] = [string] >> $InParams["ProcessStartupInformation"] = [object:Win32_ProcessStartup] >> >> >> "Calling win32_process : Create with Parameters :" >> $inparams.get_properties() | select name,Value >> >> >> $R = $mc.InvokeMethod($Method, $inParams, $Null) >> "Result : " >> $R >> >> >> "Thomas Lee [MVP]" wrote: >> >>> Brandon Shell wrote: >>> > I appologize if this has been asked before, but I couldnt find any >>> > reference. >>> > >>> > Goal: >>> > ----- >>> > Basically I just want to run an App that resides in >>> > C:\windows\system32 of >>> > the remote machine. I normally just use psexec \\server App.exe >>> > Is there a more powershellish way to do this? >>> >>> Take a look at the ps tools from winternals - these may help >>> >>> -- >>> Thomas Lee >>> DoctorDns@gmail.com >>> > > |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: HowTo: Run a Command (.exe or .cmd) on a Remote Machine //o// [MVP] wrote: > You can use WMI > > MowPS>(new-object > management.ManagementClass('\\computer\root\cimv2:win32_process')).InvokeMethod('Create','calc.exe' > ) > 0 > > Note that calc is just an test example, it is not interactive lanched remove > > Sample Script : > http://mow001.blogspot.com/2006/03/m...on-update.html > > # win32_process Create-Method Sample Script > # Created by Get-WmiMethodHelp (v3) > # /\/\o\/\/ 2006 > # Fill InParams values before Executing > # InParams that are Remarked (#) are Optional > > > $Class = "win32_process" > $Method = "Create" > $MP = new-object system.management.ManagementPath > $MP.Server = "." > $MP.NamespacePath = "root\cimv2" > $MP.ClassName = $Class > > > $MC = new-object system.management.ManagementClass($MP) > $InParams = $mc.GetMethodParameters($Method) > > > $InParams["CommandLine"] = [string] > $InParams["CurrentDirectory"] = [string] > $InParams["ProcessStartupInformation"] = [object:Win32_ProcessStartup] > > > "Calling win32_process : Create with Parameters :" > $inparams.get_properties() | select name,Value > > > $R = $mc.InvokeMethod($Method, $inParams, $Null) > "Result : " > $R What about credentials?? ;-) Thomas |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Create a folder on a remote machine? | Gerry Hickman | PowerShell | 16 | 03-18-2008 04:53 PM |
| checked for logged on user on remote machine + remote reboot | Ben Christian | PowerShell | 2 | 03-10-2008 06:52 PM |
| execute command on remote system | Justin Rich | PowerShell | 3 | 11-30-2007 08:40 AM |
| getting remote machine directory | IT Staff | PowerShell | 3 | 07-19-2007 04:11 AM |
| remote desktop howto | vista | Vista networking & sharing | 4 | 12-11-2006 03:01 PM |