Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the System Directory path in a program

Status
Not open for further replies.

sgdev

Technical User
Jan 17, 2002
14
GB
Please could anyone let me know if it is possible to change the path of the system directory in a program which VB picks up from the registry, and what code is required

Thanks
 
I am not sure about what you are trying to do. The path of the system directory will never change (that is where the OS is). Are you trying to change the starting point for a common dialog box or something? Anything is possible, the problem is I only have one lifetime.[thumbsup2]
 
Many Thanks for your reply.
I'm trying to get VB to send a message through Lotus notes.
The only problem is when I try to run it the program looks for the notes.ini in the c:\winnt\system directory and errors saying it cannot find this file as it exist on another drive x:\notes. The c:\ is read only. I was hoping that I could repoint vb to look for this file as x:\notes.

I think the only option will be for it to be put on the c: drive.

Thanks again for your help.

 
You can change the current working drive while your program is running by doing this
[tt]
ChDrive "D" ' Make "D" the current drive.

' Change current directory or folder to "MYDIR".

ChDir "MYDIR"

' Assume "C:" is the current drive. The following statement changes
' the default directory on drive "D:". "C:" remains the current drive.

ChDir "D:\MYDIR"
[/tt]


Craig, mailto:sander@cogeco.ca

"Procrastination is the art of keeping up with yesterday."

I hope my post was helpful!!!
 
Thanks for your email Craig,

The commands you've posted to change the drive and directory will come in very useful.

Unfortuately the vb program must be looking at the system path in the windows registry (which I cannot change), because even though I've changed the current path to x:\notes the program still looks in c:\winnt\system


Thanks, again
Jas
 
Do you have a code sample of how VB is sending the message through Lotus Notes? That might clear up what you are trying to do. Anything is possible, the problem is I only have one lifetime.[thumbsup2]
 
Hi, here's a sample copy of code

Private Sub Command3_Click()

Dim sDatabase As String
Dim sServer As String
Dim sWindowsPath As String


sServer = "UK_RLT/AS/RTY"
sDatabase = "Mail\rtl101.nsf"

Dim Session As Object
ChDir "x:\notes"
MsgBox (App.Path)

Set Session = CreateObject("Notes.NotesSession")
Dim DataBase As Object
Set DataBase = Session.GETDATABASE(sServer, sDatabase)
DataBase.OPENMAIL
Dim Document As Object
Set Document = DataBase.CREATEDOCUMENT()

Document.Form = "Memo"

With Document
.SendTo = "rtl101@csc.com"
.Subject = "Test1 OLE automation"
.Body = "Test1 OLE"
.From = Session.COMMONUSERNAME
.SAVEMESSAGEONSEND = True
.SEND True
End With

End Sub

Cheers
Jas
 
That is still going to give you a problem. If you read through my above examples. ChDir "D:\MYDIR" will change the current drive on D: drive to \MYDIR, but the curretn drive would stay as C:. You need to change it to this.
[tt]
ChDrive "x"
ChDir "x:\notes"
[/tt] Craig, mailto:sander@cogeco.ca

"Procrastination is the art of keeping up with yesterday."

I hope my post was helpful!!!
 
Thanks for the info.

I've put this in the code but VB still look for the notes.ini file in the c:\WINNT\system32 directory

When this line of code
Set Session = CreateObject("Notes.NotesSession")
is executed, I get the following error message
The NOTES.INI file cannot be found on the search path(PATH): C:\WINNT\system32\notes.ini

 
I'm wondering if Notes.NoteSession has this as a default. Have you tried this.
[tt]
Dim Session As Object
ChDrive "x"
ChDir "x:\notes"
MsgBox (App.Path)

Set Session = CreateObject("Notes.NotesSession")
[/tt] Craig, mailto:sander@cogeco.ca

"Procrastination is the art of keeping up with yesterday."

I hope my post was helpful!!!
 
Hi Craig

I've tried the code you gave
Dim Session As Object
ChDrive "x"
ChDir "x:\notes"
MsgBox (App.Path)

Set Session = CreateObject("Notes.NotesSession")

and the messagebox return x:\notes but unfortunately I still get the error message "The NOTES.INI file cannot be found on the search path(PATH): C:\WINNT\system32\notes.ini"

Thanks anyway,

Jas


 
Okay I have something that may be a dirty fix. You can set up the directory x:\Notes with a variable. Hold down ALT and double click my computer to get the System Properties window. Click the Environment tab and add a new variable
NotesDir with the path X:\notes. Thin in your code you would call it with $NotesDir I think? Craig, mailto:sander@cogeco.ca

"Procrastination is the art of keeping up with yesterday."

I hope my post was helpful!!!
 
What happens when you try and open Notes normally on the development machine?
 
Hi Craig Thanks for your reply.

I've added the variable on the environment tab, but I am not sure how I would access this in the code.

Jas
 
stongm

I open notes using a shortcut on the windows toolbar

which has the following

Target c:\notes\notes.exe

Start in h:\notes



Thanks for your response
Jas
 
Sorry typing error in my previous response

stongm

I open notes using a shortcut on the windows toolbar

which has the following

Target c:\notes\notes.exe

Start in x:\notes



Thanks for your response
Jas



 
It looks as if Notes is hard-coded to look at C:\Winnt\System32. I would submit a problem report to IBM, as any program should either be using the %SystemRoot% enviromental variable or the GetSystemDirectory() API call.

Chip H.

 
Well, you shouild have a local notes.ini in c:\notes then, which should then have an entry for x:\notes. Unfortunately I'm not currently anywhere near a machine with Notes installed, so I can't detail the necessary entry at the moment.
 
Many Thanks chiph and strongm for your replys


I've tried to access notes with the notes.ini file in the c:\notes directory and again with the notes.ini file in the c:\winnt\system32 directory both came up with the error that the administration program could not be run when I tried to run notes as normal.

I think I'll have to go with the option of someone logging into notes manually and then the code I've now go will actually send a message.

Thank to everyone for their help
Jas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top