![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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) |
| | 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) |
| | 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) |
| | 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) |
| | 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) |
| | 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) |
| | 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 | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How to get the output of a command executed on a remote machine? | PowerShell | |||
| is there anyway to set on a remote machine "Log On As A Service" withthe SC sdset or other SC command | .NET General | |||
| How to view remote certificates installed on remote machine? | PowerShell | |||
| checked for logged on user on remote machine + remote reboot | PowerShell | |||
| remote desktop howto | Vista networking & sharing | |||