Solved

Migrating VBS Scheduled Task to VB.NET

Posted on 2004-09-20
4
416 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

776 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