Results 1 to 5 of 5

Thread: Several Questions about DOT NET

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    196

    Several Questions about DOT NET

    Hi Everyone

    I have several questions. I am making the adjustment from VB6 to VB DOT NET. Because of the mass changes in DOT NET I feel like I am starting over learning Visual Basic. So please bear with me

    The first question:
    I am writing a program in VB DOT NET, that I need to determine if Windows is running in Safe Mode. How can I accomplish this?

    The second question:
    I have the following line in my VB code:
    File.Copy(STROrginal, STRBackup, True)

    The destination is C:\Temp\Windows\Activation\Backup

    When I run the program, with the complete path for the destination already created I get an error that the directory already exists. If I delete the directory Backup I get an error that the destination directory does not exists. I have Imports System.IO at the top of the code.

    The third question:
    In VB6 you can require variable declaration, how can this be required in DOT NET or is it even necessary

    Last questions
    I currently have 14 systems that I need to load Win 98 onto. (Yea I know out of date crap, but they were donated to a preschool, and had password protected NT 4, might have been 3.51, on them, only 200 Meg hertz PII, Some have... gulp.... EDO memory). What I have done is installed Windows on one hard drive updated it etc, and then I will ghost this drive to the others. What I want my program to do is change the names of all the PCs from PreSchool to PreSchool-1 PreSchool-2 PreSchool-3 etc. I have gotten a VB 6 program to do every thing that I want it to do. But actually change the name of the system. STRNewPCName is what the name of the PC should be and is set in the previous line.
    Currently the line that will do that reads
    environ(6) = STRNewPCName
    When this line is executed the program just drops out. I understand that this environ value is read only. If their is way, I don't mind writing the program in DOT NET. I would like this program to run under 98, 2000 and XP, if po

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Several Questions about DOT NET

    These are unrelated questions and should have been asked in separate threads. If everyone keeps each topic to one thread and each thread to one topic, and provides descriptive thread titles, and specifies the version of VB they're using, then the forum remains nice and easy for everyone to use.

    1.
    VB Code:
    1. Select Case SystemInformation.BootMode
    2.     Case BootMode.Normal
    3.         'Normal startup
    4.     Case BootMode.FailSafe
    5.         'Safe mode
    6.     Case BootMode.FailSafeWithNetwork
    7.         'Safe mode with network support.
    8. End Select
    2. It looks like you're trying to work with folders. The File class is for file manipulation. The Directory class is for folder manipulation. Having said that, the Directory class doesn't have a Copy method. You would have to create the target directory if required and then copy each file. If you're using VB 2005 then you can also use the My.Computer.FileSystem.CopyDirectory method.

    3. In VB.NET Option Explicit determines whether explicit declarations of variables are required. It is On by default. I also suggest that you turn Option Strict On.

    You should also become acquainted with the MSDN library pretty quickly. I had no idea about question 1 so I went to MSDN and searched for <"safe mode" ".net"> and the BootMode enumeration was the first match.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Fanatic Member dom_stapleton's Avatar
    Join Date
    Sep 2005
    Location
    Leigh-on-Sea, UK
    Posts
    665

    Re: Several Questions about DOT NET

    I use Microsoft Visual Basic 2008 Express Edition.

    If my post has been helpful, please rate it, unless you don't believe in Karma... which actually I don't!

    Resources:
    Visual Basic Tutorials (1, 2) | MSDN Library | Google | Krugle | Search Forums

    Free components:
    Windows Forms Components | XP Common Controls Library

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    196

    Re: Several Questions about DOT NET

    # 1
    Thanks it worked exactly like I wanted. I want the system to be running in safemode to copy certain files. Is it possible to have VB make the necessary change in the MSConfig to have the computer reboot in safe mode. I did do a search in MSDN library and a VB DOT NET book and the only thing I could find I was not sure if it was for VB or not. ExitWindowsEx(). I entered this into windows and an error was presented that ExitWindowsEx was not defined

    # 2
    Actually I'm attempting to work with Files and Directories. I am attempting to copy two files from one directory to another. If the destination does not exist it will be created, however I have not gotten that far just yet

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Several Questions about DOT NET

    ExitWindowsEx is a Windows API function, so you must declare it first in order to use it in your code. It's a popular one so you'll find examples already posted on the forum. If you want to know the details of what the function can do then you should search MSDN. If you're going to use APi functions you may also like to check out the signature of fellow member gigemboy for some useful tools.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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