|
| |||||||||
| Tags: command, command line, execute, psexec exe, remote computer |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to execute a command in a remote computer?
Hi, I have a shared folder on a server and I have to remotely execute a command on some files. What services must be running on the server to do the job? Essentials or System Center Configuration Manager. I want to consider methods that are available directly from the command line or script files, as well as not require pre-installation of agents. What are the way's to run a command on a remote computer? |
|
#2
| ||||
| ||||
| Re: How to execute a command in a remote computer?
To solve this problem is a command line utility PsExec.exe. which you can freely download from Windows SysInternals. It does not require installation of the system, you can simply copy it into one of the folders contained in the environment variable% path%, and cause of any shell: Cmd, or PowerShell. Use PsExec very simple. For example, to execute ipconfig / flushdns on the computer main, sufficient to run the following command: psexec\\main ipconfig/flushdns Ipconfig command will be run on your computer under your main credentials. After completion ipconfig all text output will be transferred to your computer, and in addition will be returned to the team's exit code (error code). If the command is successful, it will be equal to 0. The -d tells PsExec unnecessary to wait for that command, but rather just run it and forget it. In this case, we do not receive the output from the console utility, but we can not wait for the completion of the previous command to run other. This is very useful if you need to run, for example, the installer program on multiple computers. By default PsExec executes commands in quiet mode, ie a system where the command is executed, will not show any windows or dialogs. However, it is possible to change this behavior by using a key-i. After that you can specify the number of sessions in which the display window, but you can not specify, then the interface will be displayed in a console session. Thus, to display a window with information about the operating system on the computer main, should run PsExec thus: psexec-i\\main winver.exe If you want to run on several computers, you will be useful to read their names from a text file list. psexec @ c:\comps.txt systeminfo.exe Well, one of the most useful abilities PsExec is the possibility of interactive input / output redirection between computers, allowing us to run, such as cmd.exe on a remote server, and give him commands and receive results on your computer. |
|
#3
| ||||
| ||||
| Re: How to execute a command in a remote computer?
Windows Script Host also has the ability to run scripts on other computers. However, this function has not been very popular, and most likely due to the fact that demands too much of the preparatory activities and in return provides little opportunity. But I still talk about this method, because he might be useful. So, to run the script on another computer using WSH, we need to do the following: Administrator rights on the remote computer. It goes without saying, is
Well, after all these procedures, you can try to run your script on another computer. A sample script that uses this technology: WSH remote scripting (VBScript) Code: Set objController = CreateObject ( "WshController") Set objRemoteScript = objController.CreateScript ( "C: \test.vbs", "PC5") WScript.ConnectObject objRemoteScript, "remote_" objRemoteScript.Execute Do While objRemoteScript.Status <> 1 WScript.Sleep 1000 Loop MsgBox "Script complete" Sub remote_Error Dim objError Set objError = objRemoteScript.Error WScript.Echo "Error - Line:" & objError.Line & _ ", Char:" & objError.Character & vbCrLf & _ "Description:" & objError.Description WScript.Quit -1 End Sub |
|
#4
| ||||
| ||||
| Re: How to execute a command in a remote computer?
You can try Windows PowerShell 2.0 on remote computer. Infrastructure PowerShell Remoting is based on WinRM version 2.0, and therefore inherits all the advantages of this technology, such as encryption of data transferred, and the opportunity to work on standard ports HTTP / HTTPS. But thanks to the rich possibilities of language Windows PowerShell, and his ability to work with objects, we have even more possibilities. At the moment the package WinRM2.0 also is in beta and available for download only for Windows Vista and Windows 2008. In Windows 7 and Windows Server 2008R2, he will be installed initially as PowerShell 2.0. Before you take all these advantages, PowerShell Remoting should be intensified on the management, and managed computers. To do this simply by running the cmdlet (command Windows PowerShell) Enable-PSRemoting. And if you add a key-Force is no evidence requested will not be. This cmdlet if necessary will winrs quickconfig, and create an exception in the firewall Windows, so no additional action is needed. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to execute a command in a remote computer?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Execute a batch file on a remote computer? | Chris D | Windows Server Help | 6 | 20-01-2011 11:09 PM |
| Execute dos command in java | Gillian Anderson | Software Development | 4 | 22-03-2010 02:21 PM |
| The command failed to execute | Sheldon | Windows Vista Mail | 19 | 28-07-2009 03:30 AM |
| Command Failed To Execute | Leary Sooter | Windows Vista Mail | 6 | 27-06-2009 07:18 AM |
| Windows Mail Command "The Command Failed To Execute" | Rainald Taesler | Windows Vista Mail | 2 | 17-06-2009 01:52 AM |