473,387 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to run vbscript from C++ code?

Hi all,
How to vb script from a C++ code.

the script is like:

Function execute()
.
.
.
.
.
.
.
execute = obj.xml 'obj.xml is a xml
End Function

the script is working fine if i write it in a vbs file and double click on it.
but how to call it from a C++ code.

I tried with IScriptControl::Run but the its not giving any output.

SAFEARRAYBOUND rgsabound[] = { 0, 0 }; // 0 elements, 0-based
USES_CONVERSION;

psa = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
if (!psa)
{
return E_OUTOFMEMORY;
}

_variant_t outpar = m_pScriptControl->(m_bstrFunction, &psa);
// _bstrFunction = execute

but after execution of this statement outpar is empty.
Feb 20 '08 #1
2 13452
weaknessforcats
9,208 Expert Mod 8TB
Can you not use a system call?

Expand|Select|Wrap|Line Numbers
  1. system("myfile.vbs");
  2.  
Feb 20 '08 #2
Can you not use a system call?

Expand|Select|Wrap|Line Numbers
  1. system("myfile.vbs");
  2.  

I havent tried with system().
i was using the same code previously but at that time i was creating xml by concatnation of values like
resultset = resultset & "<row "
resultset = resultset & value
resultset = resultset & "/>
and then
execute = resultset

at that time the function IScriptControl::Run() gives me what i was expecting. but now i changed the script which generate the xml directly using a COM dll (the dll is registered) but now Run() is failing.
Again if i write the same script in file with message box to display the xml and run it by double clicking it, i can see the results on messagebox means there is no problem with the new xml generator object. it is doing his job. but dont know why Run() is failing?
Feb 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Frank | last post by:
When I used IE 6.0 to view the ASP page on Window 2000 server PC, I encountered the error message: "Expected end of statement". The ASP page code is as:...
0
by: Dan | last post by:
Hello, I've been asked by my supervisor to document VBScript code in our existing ASP classic pages .. primarily, what hooks we've got into our SQL databases using ADO. Right now, I've...
2
by: duncan | last post by:
why does this work :- <HEAD> ...... <SCRIPT LANGUAGE="javascript"> function test() { alert("test 1") } </SCRIPT>
10
by: Shadow Lynx | last post by:
That subject packs a whallop, so let me explain in better detail what's happening and how it relates to ASPX pages... In a nutshell, if the first <script /on a page is of type "text/vbscript",...
6
by: rishabhshrivastava | last post by:
Hello All, I am using ASP.NET 2.0 and I am experiencing a problem using vbscript that is this script on client side is preventing the postback of my controls. I have a dropdownlist which is...
1
by: Andrew Wan | last post by:
How can VBScript code access JScript code variables in the same ASP page? <SCRIPT LANGAUGE="VBScript"> Dim a a = 10 </SCRIPT> <SCRIPT LANGUAGE="JScript"> Response.Write(a); </SCRIPT>
2
by: moodyman13 | last post by:
Hi All, Im in a bit of pickle with ASP and VBscript variable and hope someone could get me some advice. Theres a FORM Ive created in ASP and its purpose is to capture the name(s) of users....
1
by: Igor Ladnik | last post by:
We are dealing with .NET server component and COM clients written with VB6 and VBScript. And there are some problems we faced (please see code below). 1. Managed type System Drawing.Color is...
3
ashishp
by: ashishp | last post by:
I am not getting the rt kind of code for the following : Accept any date in the msg box & display day for that date Pls can anyone help me with the code.
3
by: sabitawoonna | last post by:
strMsg = "This script will test the HardwareInfo object by reporting the values for the hardware info properties." strMsg = strMsg & " Please check the bios and computer properties to verify the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.