There is any way to run vbscript directly at the wscript or cscript command line

I want to run the vbs command from the command line, as it would be with a batch call

cmd.exe /c "echo.Hello World! & pause" 

Obviously this doesn't work

 wscript /C MsgBox("Hello world") 

I can print vbs and then call the temporary file and then delete it

 cmd.exe /c "echo. [VBSCODE] > temp.vbs & wscript temp.vbs & del temp.vbs" 

but it’s too dirty, and I don’t want the hint to appear.

+4
source share
3 answers

this works directly on the command line:

mshta vbscript: Run ("MsgBox (" message "", 64, "" atitle "") (window.close) ")

+9
source

VBScript requires a file for its source code. You want to specify stdin as a "file", but there is no mechanism for this. Thus, the answer is no: you cannot generate and run VBS code from the command line without using a temporary file.

Most users use a batch script package to write VBS temp code, execute, and then remove the temporary code, as demonstrated by the user agent.

I discovered a mechanism for embedding VBS code in a batch file without the need for a temporary file. But it is not very beautiful. See Can I embed and run VBScript in a batch file without using a temporary file?

It is much more beneficial to embed JScript in a batch file .

+1
source

avoid typing again and again, just create bat with commands to run

sovb.bat

 @echo off echo %* >%temp%\temp.vbs wscript %temp%\temp.vbs del %temp%\temp.vbs 

and then from the command line, call it

 sovb MsgBox("Hello World") 
0
source

Source: https://habr.com/ru/post/1442665/


All Articles