Prev: Posting NNTP message with script.
Next: reading registry entries whose name have backslashes in them
From: Sherwood Hu on 30 Nov 2009 12:53 I need to add scripting capabilities to an existing application. I read some docuentation about Active Scripting and wrote a small application to execute VBScript code. The program seems working fine with simple code such as i=10. However, When I try to call MsgBox function, it returned an error message that permission is declined. I noticed that MsgBox can't be used in classic ASP. However, my case is a desktop application. Is there something I can do to enabel MsgBox function on scripting. Or Microsoft has put some restrictions on VBScript code executed from custom programs. I am running on Vista.
From: Pegasus [MVP] on 30 Nov 2009 13:09 "Sherwood Hu" <sherwood(a)morovia.com> wrote in message news:FACF0B5D-EAD5-40AD-B25B-401BE24E0F9A(a)microsoft.com... >I need to add scripting capabilities to an existing application. I read >some docuentation about Active Scripting and wrote a small application to >execute VBScript code. > > The program seems working fine with simple code such as i=10. However, > When I try to call MsgBox function, it returned an error message that > permission is declined. > > I noticed that MsgBox can't be used in classic ASP. However, my case is a > desktop application. > > Is there something I can do to enabel MsgBox function on scripting. Or > Microsoft has put some restrictions on VBScript code executed from custom > programs. I am running on Vista. Hard to say unless you post your script (or at least the relevant script fragment).
From: "Dave "Crash" Dummy" on 30 Nov 2009 13:16 Sherwood Hu wrote: > I need to add scripting capabilities to an existing application. I > read some docuentation about Active Scripting and wrote a small > application to execute VBScript code. > > The program seems working fine with simple code such as i=10. > However, When I try to call MsgBox function, it returned an error > message that permission is declined. > > I noticed that MsgBox can't be used in classic ASP. However, my case > is a desktop application. > > Is there something I can do to enabel MsgBox function on scripting. > Or Microsoft has put some restrictions on VBScript code executed from > custom programs. I am running on Vista. It should work. I have no problem with popup boxes using local scripts (.VBS) or client side browser scripts. What do you mean by "existing application?" This one line program should work if run from Explorer: --------msgbox.vbs-------------- msgbox "Hello, World!" -------------------------------------- -- Crash "The real question is not whether machines think but whether men do." ~ B. F. Skinner ~
From: Sherwood Hu on 30 Nov 2009 13:20
The code (written in C++) looks like this: ScriptEngine* se = new ScriptEngine(); bool rc = se->Initialize(); assert(rc==true); // const wchar_t code[] = L"MsgBox \"this is good.\", 0 "; const wchar_t code[] = L" " L"Dim fso, MyFile\r\n" L"Set fso = CreateObject(\"Scripting.FileSystemObject\")\r\n" L"Set MyFile = fso.CreateTextFile(\"c:\\testfile.txt\", True)\r\n" L"MyFile.WriteLine(\"This is a test.\")\r\n" L"MyFile.Close\r\n"; rc = se->Execute(code); Note that a lot of code is inside ScriptEngine class (which implements IActiveScriptSite interface and connects to VBScript engine). The second script worked just fine - a file was created under c:\ successfully. The first script returned an error. Inside IActiveScriptSite::OnScriptError it reports: "Script error detected at line 0. Description: Permission denied: 'MsgBox'" |