Answer the question
In order to leave comments, you need to log in
How to run code on a remote machine using non-standard or standard Windows tools?
Greetings.
There is a person who has a local server of one toy spinning, IP is static, the essence of the task is to somehow run a batch file on this remote machine.
At the moment there is a direct connection to the desired folder where I can modify the server, there is also a batch file for the server reboot.
1. I tried to use psexec, added a key to the registry on a remote machine, also changed the local security policy (I don’t remember which parameter is related to the user’s authorization in the system, changed it from a guest to a regular one).
But this did not bear fruit, because I catch "couldn access" for unknown reasons, the user under which I sit in the general access has both read and write rights.
Answer the question
In order to leave comments, you need to log in
On account of "couldn't access" - interferes with UAC. To bypass it (for remote access to a computer with administrator rights), you need to set the key in the registry:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
LocalAccountTokenFilterPolicy [REG_DWORD] = 1
And, of course, you need to execute from a user with administrator rights.
psexec works fine.
There is also a native tool - wmic .
For wmic, you can set the remote username and password in the options (see wmic /?). The user must also have administrator rights on the remote computer.
There is also winrm, but I won’t tell you right away how to cook it correctly.
PS: the remote launch tools in Windows are for the needs of the administrator, so administrator rights are required everywhere. If you need without admin rights, then you can set up a remote desktop and let people come in via RDP and run whatever they need with their hands.
PPS: if the application somehow interacts with the user interface (opens windows, etc., etc.), then when running remotely via psexec or wmic, there may be difficulties, because for remote launch, a separate user session is created that is not associated with a local session. Accordingly, the application will have nowhere to open its windows. Because of this, it may not be possible to launch the application remotely. Console applications run normally - they automatically redirect output to your remote machine. In psexec, you must use the -i switch to allow an application to open windows. There is no such key in wmic, in my opinion.
If there is access to files, then a crutch but quite a working version with a batch file is also possible.
Create a task in the scheduler to launch a batch file every five minutes, for example.
Your batch file is empty. Nothing comes through.
How to do something - write down the necessary commands in the batch file.
The next time you run them, they will be executed.
Option 1. Install the openssh server on your computer and connect via ssh to the command line.
Option 2. Any web server will allow you to execute the batch file in the usual way - in mybat.php you can embed the exec external command
Option 3. Apache HTTPD allows you to execute CGI, that is, you can force it to execute your batch files.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question