[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Migrating VBS Scheduled Task to VB.NET

Posted on 2004-09-20
4
Medium Priority
?
423 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

650 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