Results 1 to 10 of 10

Thread: [VB6] BatchRtb 2

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    [VB6] BatchRtb 2

    Since I am almost 100% retired now and doing a lot less VB6 programming I have been looking for things in my toolkit that might be worth sharing with the remaining VB6 community.

    I have done a big rewrite of my BatchRtb Class. Here is the main ReadMe:

    Code:
    ========
    BatchRtb Version 2.0
    ========
    
    BatchRtb is a VB6 class for working with RTF data in batch programs.
    
    Instead of a RichTextBox control it creates an invisible RichEdit
    control and exposes its Text Object Model (TOM) ITextDocument
    interface.  A few additional methods and properties are provided for
    opening, saving, and clearing RTF data.
    
    Open and save operations accept:
    
        o A file name.
        o A Byte array.
        o An IStream object.
        o A ShStream object (another provided class also used internally).
        o An ADODB.Stream object.
    
    These should all contain raw RTF data.
    
    
    Notes:
    
        Edanmo's olelib.tlb is required for compiling, but is of course
        not needed at run time and does not need to be deployed.  A recent
        copy has been included.
    
        If necessary you could even create and compile an ActiveX DLL
        Project exposing the BatchRtb class and perhaps the ShStream class.
        Then this can be used from VBScript in WSH scripts, IIS ASP
        scripts, etc. (anywhere a 32-bit ActiveX DLL can be used).
    
        Several demo/test Projects using BatchRtb are included.
    
    
    Some uses:
    
        o Command line programs.  Local, via PsExec.exe, etc.
        o Batch unattended scheduled tasks.
        o Services.
        o Or anywhere that you don't have a Form or UserControl you can
          site a RichTextBox or InkEdit control on.
    This isn't for everyone. Few people are doing Service development, ASP scripting, etc. Most don't even have a clue how to use a CLI (cmd.exe) window, let alone schedule a non-interactive batch task using Task Scheduler any more.

    But this code may contain techniques you could employ in your own programs.


    BatchRtb 2.0 has been tested on Windows 10 Fall Creator's Update but not on anything else yet. It should work on anything from Windows Vista on up. I'm not sure it could be made to work on Win9x but I think it could be reworked to run on NT 4.0 on up by rewriting the ShStream class - as long as a recent version of ADO (2.5 or later) is installed. The ADO requirement could also be stripped out if necessary.

    I haven't done exhaustive testing so bugs may remain in this release. But the attachment contains a number of test case Projects that exercise most of its operations.
    Attached Files Attached Files

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] BatchRtb 2

    Note:

    Most of the size of the attachment above comes from including Edanmo's olelib.tlb version 1.7, which you may already have.

    TLB's do not carry compiled object code, and I have been careful to give him liberal credit. If the moderators object I can always re-post without that type library though. You can go get it yourself from Eduardo's web site (assuming it is still up when you read this) or substitute your own equivalent. BatchRtb is only using a very few things defined in the olelib.tlb type library.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] BatchRtb 2

    Here is a quick and dirty small helper utility for anyone who wants to schedule an unattended batch job.

    This is probably going to be easier for most people to use than the Local Security Policy administrative control panel applet, and this tool should work even on Windows editions that do not include the applet. These are "Home," "Basic," etc. editions. In most cases "Pro," "Enterprise," etc. include that applet.

    The code itself might be useful to study by anyone who wants to query or change other security policy items.

    Screenshot:

    Name:  sshot.png
Views: 374
Size:  4.4 KB

    Note that an "account name" is a user name. However people sometimes will "rename" a user account after creating it, which often just assigns a descriptive "full name" property that differs from the actual user account name.

    It contains a manifest that always requests elevation. Without elevated rights the program will get an "Access denied" error trying to query the account's rights, let alone when changing them.


    As far as I can tell this ought to work as far back as Windows XP SP1. But I have only tested it on Windows 10 Fall Creator's Update (1709).

    Most of the attachment size is due to the icon I used.
    Attached Files Attached Files

  4. #4
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    673

    Re: [VB6] BatchRtb 2

    Your code is really interesting, how could you have so much knowledge

  5. #5
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: [VB6] BatchRtb 2

    Quote Originally Posted by xxdoc123 View Post
    Your code is really interesting, how could you have so much knowledge
    Quote Originally Posted by dilettante View Post
    Since I am almost 100% retired now
    I think your answer is that Dilettante has been coding for a long, long time There's a decent chance he's been coding as long almost as long as I have been alive!

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] BatchRtb 2

    Yes, I've just been at this for a long time.
    Last edited by dilettante; Apr 9th, 2018 at 11:48 PM.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] BatchRtb 2

    BTW:

    In case this part is confusing see Deny logon as a batch job

    Determines which accounts are prevented from being able to log on as a batch job. This policy setting supercedes the Log on as a batch job policy setting if a user account is subject to both policies.

    This user right is defined in the Default Domain Controller Group Policy object (GPO) and in the local security policy of workstations and servers.

    By default, there are no users denied logon as a batch job.
    I've never been sure why we have both of these rights, a positive one and this negative one.

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] BatchRtb 2

    After some checking (though not actual testing), this ought to work all the way back to NT 3.51 though of course it won't work at all on Win9x. The only stumbling might be in Sub Main, which could be altered to:

    Code:
    Private Sub Main()
        On Error Resume Next
        InitCommonControlsVB
        On Error GoTo 0
        Form1.Show
    End Sub

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] BatchRtb 2

    If you want a tutorial, this one looks pretty good:

    Using Task Scheduler to Run Processes Later

    While the "Basic Task" creation wizard described on the 1st page there is handy, you'll want to keep on reading if you want to learn how to create unattended batch tasks that can run when you are not logged on interactively.

  10. #10
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: [VB6] BatchRtb 2

    If you're just doing a 1 form app, you can move that Initialization code to Form_Initialize.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width