Solved

Migrating VBS Scheduled Task to VB.NET

Posted on 2004-09-20
4
419 Views
Last Modified: 2008-02-01
Hi experts.

Here's what I'm trying to do.  We've got a series of tasks that run on our servers at a given time interval.  Right now all these scheduled tasks are just vbScript files that are parsed by the Windows Scripting Host.  This solution has been working for a while, but I'd like to migrate a few of them to VB.NET and compile them into .exe's.

I've had pretty good luck converting some of the simple ones over (ones that just read or write to a database, or copy files to a backup server).

With the file I'm currently trying to migrate, I'm having trouble with the old "CreateObject()" syntax.  This particular object is an instance of an object defined in a .dll that is registered on the server.  In vbScript it was a simple 'Set objWhatever = CreateObject("Whatever")', however, .NET doesn't do Set and Let anymore, so my syntax is something like 'Dim objWhatever AS NEW Whatever". <--- This isn't working.

I'm guessing that I have to reference the class of the object with some fully qualified name (including the namespace or something), but I haven't figured out just how to do it.

Please note, I am not using Visual Studio.  I'm coding by hand (in a text editor) and compiling on the command line.

Any expert input would be appreciated.

-a
0
Comment
Question by:locke_a
4 Comments
 
LVL 12

Expert Comment

by:fulscher
ID: 12107485
A few thoughts:

Converting to VB.Net will NOT give you that much of a performance advantage, unless you have lots of calculations and user forms. Most of the processing time is probably spent in the called objects, so you won't save much.

You might want to check out an alternative development environment, like #develop (http://www.icsharpcode.net/OpenSource/SD/Default.aspx) or Mono (if you want to switch to C# - check out http://www.mono-project.com/about/index.html). Both are Open Source. This may - or may not - help with all the refence stuff.

Then, object reference is completely different in VB.NET - if you're familiar with earlier version of VB, you'll have to re-learn. Basically, everything is an object and SET and LET do not exist any more. Your code sample therefore is correct:

Dim objWhatever as New ClassWhatever

As you have thought, it's a problem of the references. You need an additional XML files which describes the references. Unfortunately, COM and ActiveX are not supported in .NET; if you want to use them, you have to create a so-called assembly (which wraps the calls). I think there's a utility to do so. Also, you need an XML file for your project which described the assembly.

Here's an extract of a file with a reference to a COM assembly:

<VisualStudioProject>
    <VisualBasic
        ProjectType = "Local"
        ProductVersion = "7.10.3077"
        SchemaVersion = "2.0"
        ProjectGuid = "{4FBC1D50-50D7-40F5-8B75-6790185AE59A}"
    >
        <Build>
            <References>
                <Reference
                    Name = "StormSource.Compact.GPS"
                    AssemblyName = "StormSource.Compact.GPS"
                    HintPath = "C:\Program Files\StormSource Software\GPS.NET Global Positioning SDK\Visual Studio.NET Compact Framework\bin\StormSource.Compact.GPS.dll"
                    AssemblyFolderKey = "hklm\dn\stormsource.compact.gps.1.3.5000.0"
                />
            </References>
        </Build>
    </VisualBasic>
</VisualStudioProject>

As you can see, there's also stuff related to the registry (AssemblyFolderKey).

Maybe another Expert can explain how to create all this stuff from the command line - I can't. To be honest, though, I doubt whether it's worth the effort...

Jan
0
 
LVL 11

Author Comment

by:locke_a
ID: 12298638
Admin,

I have not yet gotten an answer for this that works for me.

This question can be closed, however I don't feel that points should be awarded.

-A
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12327324
PAQed, with points refunded (250)

Computer101
E-E Admin
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question