Home > Blockchain >  Multiple commands on button click callShellApplication?
Multiple commands on button click callShellApplication?

Time:11-29

in my JScript HTA script I have a button that executes a CMD command when I press it: <button onclick="callShellApplication('ipconfig')">Your IP-Adress</button> But this is only one command and I want to execute several. For example @echo hello ipconfig, I need this because the system on which I execute the command has a CMD block, with the first command it always puts a cryptic character in front of it only with the second command is the command executed. So to get around that I want to execute two commands. How do I do that?

Best regards, jcjms

CodePudding user response:

I will be critiqued for a one line answer rather than adding a full related code block but this is a minor mod from someone else's answer at https://stackoverflow.com/a/70138712/10802527

    <button onclick="callShellApplication('cmd /d /c echo/ &ipconfig')">IP-Adress</button>

It is not perfect as it throws the black console widow up for a second before feedback is captured.

My excuse for the simplistic answer is it does exactly what was requested i.e. inject an echo before calling ipconfig.

It seems there may be some Admin autorun trap in cmd chain and using /D should help avoid that if also necessary.

If the echo is needed to acknowledge an autorun message, then it will not be needed if /d stops it acting thus that line may then simplified to:-

    <button onclick="callShellApplication('cmd /d /r ipconfig /all')">IP-Adress</button>
  • Related