|
-
Aug 6th, 2006, 08:20 PM
#1
Thread Starter
Addicted Member
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
-
Aug 6th, 2006, 08:40 PM
#2
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:
Select Case SystemInformation.BootMode
Case BootMode.Normal
'Normal startup
Case BootMode.FailSafe
'Safe mode
Case BootMode.FailSafeWithNetwork
'Safe mode with network support.
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.
-
Aug 6th, 2006, 09:02 PM
#3
Fanatic Member
Re: Several Questions about DOT NET
-
Aug 6th, 2006, 09:45 PM
#4
Thread Starter
Addicted Member
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
-
Aug 6th, 2006, 10:20 PM
#5
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|