Запустите команду в фоновом режиме в PSEXEC

1496
Pablo

Команда ниже работает нормально и освобождает, обновляя удаленный IP-адрес.

PsExec.exe \\10.10.1.12 -accepteula -u Administrator -p 1 cmd /c "ipconfig /release && ipconfig /renew" 

Однако, поскольку IP-соединение теряется после release, PsExec некоторое время ждет, пока не возникнет ошибка. Я знаю, что могу указать время ожидания, но чтобы различать реальные ошибки, я бы хотел запускать команды выше в фоновом режиме. Я хотел бы использовать start /B, но мои попытки потерпели неудачу, такие как:

PsExec.exe \\10.10.1.12 -accepteula -u Administrator -p 1 "cmd /c start /B "ipconfig /release && ipconfig /renew"" 

Ищете правильный способ использования start /B.

2
Возможно, стоит использовать опцию -d Не ждите завершения процесса (неинтерактивно). Вы все равно получите код ошибки для сбоя и идентификатор процесса, если он запустится Shaun Vermaak 9 лет назад 0

3 ответа на вопрос

1
Pimp Juice IT

Create a batch file with a name such as ReleaseRenewIP.cmd with the following:

@ECHO OFF IPCONFIG /release && IPCONFIG /renew 

Once this is complete run the below remotely:

PSEXEC \\10.10.1.12 -s -c ReleaseRenewIP.cmd 

These PSExec command options do the following:

-c Copy the specified program to the remote system for execution. If you omit this option the application must be in the system path on the remote system. -s Run the remote process in the System account. 
0
Ƭᴇcʜιᴇ007

You can't just double-quote double quotes (nested quotes); you need to 'escape' the inner quotes so that they're not seen as termination for the current statement.

In Windows' command line, you escape double quotes by doubling them up. So try:

PsExec.exe \\10.10.1.12 -accepteula -u Administrator -p 1 "cmd /c start /B ""ipconfig /release && ipconfig /renew"""

I think you may also have to wrap cmd /c's command argument in quotes as well, so perhaps:

PsExec.exe \\10.10.1.12 -accepteula -u Administrator -p 1 "cmd /c ""start /B ""ipconfig /release && ipconfig /renew"""""

`PsExec не удалось запустить cmd / c" start / B "ipconfig / release && ipconfig / renew" "10.10.1.12: система не может найти указанный путь. Pablo 9 лет назад 0
Примеры могут быть не совсем правильными (я не проверил их полностью), но смысл ответа остается в силе. :) Пожалуйста, обновите свой вопрос, включив в него различные версии команд, которые вы пробовали, и каковы были в результате ошибки для каждой. Ƭᴇcʜιᴇ007 9 лет назад 0
Кроме того, вы заставили команду `start / b` (отдельно) работать так, как задумано в тестировании? Ƭᴇcʜιᴇ007 9 лет назад 0
-2
crelikus

guy's basic principals first please. crawling, walking then running please!

Remember single instructions first, learn how it works, understanding what u are trying to do...from asking the question till getting the answer u need to understand what u are doing!

It needs to make sence, okay.

The same with giving commands, u need to know what must or should be your intended result, the question, the answer, the command or instruction, and how to get it. It must be able to repeatedly give the same or similar results. Please note that different OS'ses and versions of software can give different results on the same command!

U do need to know and remember this.

When u understand the single instruction or command, then try combining or stringing commands.

Here again remember commands can, may or may not interfere with each other and also react differently on different OS'ses and, or other versions of software or combinations there off (including other machines on the network may, when on or off, in or out, sometimes both, alter or give different results on the local machine you are working on).

Burnt my fingers many times.

NB: Try on one pc with a single OS in a fixed setup to be able to do or get concice or repededly the same results or outcome, before going to the next step.

With these simple steps u will be able to do anything on every type of system, new, old, even in another language than your own. Because U understand what U want and need to do.

Yes i can give the command to u ... but will u be able to give it over to another to use, or use it elswere?

Try to eliminate to many variables.

Be precise!

Enjoy what u are trying to do....happy hunting ;-)

Похожие вопросы