S
S
seoplus20192020-09-17 12:15:54
PowerShell
seoplus2019, 2020-09-17 12:15:54

How to convert cmd/bat to powerShell?

There is a code

SetLocal EnableDelayedExpansion

Set ServiceName=tbupddwu

Net Stop %ServiceName%||(
    For /F "tokens=3" %%A In ('SC queryex %ServiceName%^|Find "PID"') Do (
                TaskKill /F /T /PID %%A>nul
                Ping -n 5 127.0.0.1>nul
    )
)
Net start %ServiceName%
Pause&Exit


How to convert it to PowerShell?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Ronald McDonald, 2020-09-17
@Zoominger

Understand what it does and rewrite from scratch.

C
CityCat4, 2020-09-17
@CityCat4

Rewrite. For all his fearfulness, he does quite obvious things - he shoots some service, checks that he is dead, if not - something else brings down, then starts it again - apparently such a cunning restart of the service

M
MaxKozlov, 2020-09-17
@MaxKozlov

CityCat4 has already written the essence, but for rewriting you can get ideas here
https://social.technet.microsoft.com/Forums/lync/e...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question