Solved

Migrating VBS Scheduled Task to VB.NET

Posted on 2004-09-20
4
413 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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed, with points refunded (250)

Computer101
E-E Admin
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now