Insert msdos command into a vbscript file

Asked

Viewed 231 times

-1

I wonder if it is possible and how to insert an MSDOS command line inside a vbscript.

I have this command line to get the ID of the Anydesk program, available on the Anydesk website

@echo off
for /f "delims=" %%i in ('"C:\Program Files (x86)\AnyDesk\AnyDesk.exe" --get-id') do set CID=%%i 
echo AnyDesk ID is = %CID%
pause

That generates this result at the command prompt: inserir a descrição da imagem aqui

I wonder if it is possible to run or convert to vbscript, the purpose is to use the function "msgbox" to capture the ID that the command in msdos captures and displays at the prompt, having a result similar to this:

inserir a descrição da imagem aqui

Thanks in advance

1 answer

1


Not tested with the output of Anydesk.exe, then it may occur the output does not give in the:

WshShellExec.StdOut.ReadAll

Then I’d have to switch to:

WshShellExec.StdErr.ReadAll



strCommand = "cmd /c ""C:\Program Files (x86)\AnyDesk\AnyDesk.exe"" --get-id "
Set WshShell = CreateObject("WScript.Shell")
Set WshShellExec = WshShell.Exec(strCommand)
strOutput = WshShellExec.StdOut.ReadAll
strOutput = "AnyDesk ID is = "& strOutput
MsgBox strOutput, 64, "AnyDesk ID"

  • To do the same thing and put a copy of the ID in your ClipBoard Ctrl+C

 CreateObject("WScript.Shell").Run "cmd /c ""C:\Program Files (x86)\AnyDesk\AnyDesk.exe"" --get-id |clip", 0, True
 strOutput = CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text")
 MsgBox strOutput, 64, "AnyDesk ID"
  • Perfect!!! It was what I needed, it fits me perfectly. Thank you so much for your help. Obs* In the second option you passed, after clicking OK generates an error.

  • 1

    @M.Nunes then try to see the second, but which Windows vc uses. Good question yours! Thanks.

  • In the first option you passed, how do I get cmd strCommand = "cmd /c ""C: Program Files (x86) Anydesk Anydesk.exe"" -get-id " run invisible

  • 1

    @M.Nunes see you later... now at work... zOk?

  • 1

    @M.Nunes tried some options and n worked, I will insist... but within my time, zOk?

  • I appreciate the help, I’ve researched a lot how to hide the prompt call, but so far unsuccessful.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.