[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [trading] [amibroker] Starting AB with different data bases



PureBytes Links

Trading Reference Links


Hello,
I came across this older thread as I am hoping to be able to do the 
same thing (launch AB from the desktop with different databases).
I hope I can get some assistance from those who have used the script 
below. I eliminated the wrap arounds but continue to get errors.  I 
am lost with VBscript!

Specifically,  I am getting an error on this line:
Set oWinMgm = GetObject("WinMgmts://localhost")

The error is:
Error: 0x80041001
Code: 80041001
Source: (null)

All help much appreciated and thank you,
kris

--- In amibroker@xxxxxxxxxxxxxxx, "Greg" <gphanson2@xxxx> wrote:
> 
> Good Day Herman - no i've not had any luck. i am totally in the 
dark 
> with this. if i could get one instance working - like most other 
> things - i should be able to carry on  on my own. i hate to pester 
> fred too much though. anyway this is exactly what i'm looking for 
if 
> i can get it to work.
> 
> Greg
> --- In amibroker@xxxxxxxxxxxxxxx, "Herman van den Bergen" 
> <psytek@xxxx> wrote:
> > Thanks fred, this is nice!
> > 
> > Greg, did you get this running? I am getting errors, cleaned up 
the 
> wraps
> > but still there appear to be some hidden characters..
> > 
> > if you fixed the wraps, could you please post a zipped attachment?
> > 
> > many thanks,
> > herman
> >   -----Original Message-----
> >   From: Greg [mailto:gphanson2@x...]
> >   Sent: Thursday, December 09, 2004 10:46 AM
> >   To: amibroker@xxxxxxxxxxxxxxx
> >   Subject: Re: [trading] [amibroker] Starting AB with different 
> data bases
> > 
> > 
> > 
> >   Good Day Fred - thanks for all your work. i've a great deal to 
> learn
> >   here. again many thanks.
> > 
> >   Greg
> >   --- In amibroker@xxxxxxxxxxxxxxx, "Fred" <ftonetti@xxxx> wrote:
> >   >
> >   > Careful ... There are line wraps.
> >   >
> >   > --- In amibroker@xxxxxxxxxxxxxxx, "Fred" <ftonetti@xxxx> 
wrote:
> >   > >
> >   > > This should get you there and then some ...
> >   > >
> >   > > Put the code in a file in your AmiBroker directory.  It 
needs 
> to
> >   > > have a filetype of .vbs
> >   > >
> >   > > This will check to make sure AB is not running ... start AB
> >   > assuming
> >   > > it's not already running and load the default data base ... 
If
> >   you
> >   > > need a different one loaded then change the constant name.
> >   > >
> >   > > Option Explicit
> >   > >
> >   > > Dim oWinMgm
> >   > > Dim oProcess
> >   > > Dim oAB
> >   > > Dim oWSH
> >   > > Dim oFSO
> >   > >
> >   > > Dim iAbIsOpen
> >   > > Dim iResult
> >   > > Dim iError
> >   > > Dim sScriptName
> >   > >
> >   > > Const cstDataBaseDir = "C:\Program Files\AmiBroker\Data\"
> >   > >
> >   > > sScriptName = "Start AmiBroker"
> >   > >
> >   > > Set oWSH  = WScript.CreateObject("WScript.Shell")
> >   > > iAbIsOpen = false
> >   > >
> >   > > Err.Clear
> >   > >
> >   > > Set oWinMgm = GetObject("WinMgmts://localhost")
> >   > >
> >   > > If Err <> 0 Then
> >   > >     WScript.Echo Err.Description
> >   > >     iError = True
> >   > > End if
> >   > >
> >   > > iResult = oWSH.popup("Checking To See If Amibroker Is
> >   Running...",
> >   > > 3, sScriptName, 64)
> >   > >
> >   > > For Each oProcess in oWinMgm.ExecQuery ("select * from
> >   > Win32_Process
> >   > > where name='Broker.exe'")
> >   > >     iAbIsOpen = true
> >   > > Next
> >   > >
> >   > > If Err <> 0 Then
> >   > >     WScript.Echo Err.Description
> >   > >     iError = True
> >   > > End if
> >   > >
> >   > > If Not iAbIsOpen Then
> >   > >     iResult = oWSH.popup("Running Amibroker Now...", 3,
> >   > sScriptName,
> >   > > 64)
> >   > >     iResult = oWSH.Run ("Broker.exe", 3, false)
> >   > >     WScript.Sleep(1000)
> >   > > Else
> >   > >     iResult = oWSH.popup("Amibroker Already Running", 3,
> >   > > sScriptName, 64)
> >   > > End If
> >   > >
> >   > > If Err <> 0 Then
> >   > >     WScript.Echo Err.Description
> >   > >     iError = True
> >   > > End if
> >   > >
> >   > > set oWinMgm = Nothing
> >   > >
> >   > > If iError then
> >   > >     Quit
> >   > > End If
> >   > >
> >   > > Set oFSO = CreateObject("Scripting.FileSystemObject")
> >   > > Set oAB  = CreateObject("Broker.Application")
> >   > >
> >   > > iResult = oWSH.popup("Loading Database ...", 3, 
sScriptName, 
> 64)
> >   > > If Not oAB.LoadDatabase(cstr(cstDataBaseDir)) Then
> >   > >     MsgBox "Cant Load Database"
> >   > >     iError =true
> >   > > End
> > 
> > 
> > 
> > 
> > 
> >   Check AmiBroker web page at:
> >   http://www.amibroker.com/
> > 
> >   Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > 
> > 
> >         Yahoo! Groups Sponsor
> > 
> >         Get unlimited calls to
> > 
> >         U.S./Canada
> > 
> > 
> > 
> > 
> > ------------------------------------------------------------------
--
> --------
> > --
> >   Yahoo! Groups Links
> > 
> >     a.. To visit your group on the web, go to:
> >     http://groups.yahoo.com/group/amibroker/
> > 
> >     b.. To unsubscribe from this group, send an email to:
> >     amibroker-unsubscribe@xxxxxxxxxxxxxxx
> > 
> >     c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms 
of 
> Service.





------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/