Click here to Skip to main content
14,606,525 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am not able to run .vbs file from c++ program. plz help me to solve the problem.

What I have tried:

I am not able to run .vbs file from c++ program. plz help me to solve the problem.
Posted
Updated 26-Jun-20 4:48am
Comments
CHill60 21-Mar-16 9:44am
   
What have you actually tried?
Rate this:
Please Sign up or sign in to vote.

Solution 1

To run a VBS script see Microsoft Windows 2000 Scripting Guide - Running Scripts from the Command Line[^].

To execute a command from a C/C++ application use system, _wsystem[^], _popen, _wpopen[^] or the ShellExecute function (Windows)[^].

To get the data printed out by the script, redirect the output to a text file (see first link) and read that file afterwards or use _popen() (see example at the _popen MSDN link).
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 2

you can host a vbs script engine inside C++, using COM and Windows Script Engines[^]

It's not particularly difficult, if you have a good grasp of COM
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

try using
system("filename.vbs");
   
Comments
CHill60 26-Jun-20 12:29pm
   
As suggested in Solution 1 four years ago

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100