|
-
Feb 13th, 2008, 09:02 AM
#1
Thread Starter
Addicted Member
Reg import issue
Hi,
I had an issue with some code yesterday but have managed to get it working. The only issue I have with the code is the fact that the regimprt "file" section doesn't detect whether the file exists.
I have got code at the top which detects if the folders exist and proceeds if so, but will fail if not. However I can't figure out how I can set this up with the reg import, Any ideaS?
Code:
Private Sub regimprt_a(RegFileName As String) ' BPFTP Registry Import
wshell.Exec "regedit /s ""C:\Maintainer\BPFTP\Reg\" & RegFileName
Private Sub cmdBPFTPRepair_Click()
If objFSO.FileExists("C:\Maintainer\BPFTP\Default Settings\Default.bps") And objFSO.FolderExists("C:\Program Files\BPFTP\") Then
objFSO.CopyFile "C:\Maintainer\BPFTP\Default Settings\Default.bps", "C:\Program Files\BPFTP\Default.bps", OverwriteExisting
MsgBox "Files Copied", vbInformation + vbOKOnly, Me.Caption
regimprt_a "CacheExpiry.reg"
regimprt_a "EmailAddress.reg"
regimprt_a "LogFileName.reg"
regimprt_a "MaximumNumberRetries.reg"
regimprt_a "RetryDelay.reg"
regimprt_a "TimeoutSecs.reg"
regimprt_a "Viewer.reg"
Else
MsgBox "Copy Failed", vbCritical + vbOKOnly, Me.Caption
End If
End Sub
-
Feb 13th, 2008, 09:17 AM
#2
Addicted Member
Re: Reg import issue
You can very well use the FSO object to check the File existance before attempting to use the path in the Shell script.
You cannot include this check in the parameters of the Shell command.
Regards
Srinivasan Baskaran
India
-
Feb 13th, 2008, 10:04 AM
#3
Thread Starter
Addicted Member
Re: Reg import issue
So I can use FSO on "regedit /s ""C:\Maintainer\BPFTP\Reg\" & RegFileName to check the path?
This didn't seem to work for me. The reason I need &RegFileName as I need to check all the files.
-
Feb 13th, 2008, 12:28 PM
#4
Thread Starter
Addicted Member
Re: Reg import issue
I've now updated my code and managed to get it all working, only problem is that a message box will keep appearing several times (in this example it would appear 3 times).
It seems like my program continues to run through each file and give an outcome for each.
The code itself does the job just fine, I have also tested it by removing files from the folder and it will give the msgbox I expect, but its just the fact that I have message boxes appearing for all 3 files, which is quite annoying.
I guess the ideal scenario would be to have the program stop if it detects a file missing.
Trying to find the easyiest solution, hence it would be nice to keep this code.
Anyways heres the code.
Code:
Private Sub regimprt_b(regfilename As String) 'Net Meeting Registry Import
If objFSO.FileExists("C:\Maintainer\Video Stream\Reg\" & regfilename) Then
wshell.Exec "regedit /s ""C:\Maintainer\Video Stream\Reg\" & regfilename
'gets the .reg file name from cmdVideoStream.click
MsgBox "passed", vbInformation + vbOKOnly, Me.Caption
Else
MsgBox "File(s) missing within C:\Maintainer\Video Stream\Reg\", vbCritical + vbOKOnly, Me.Caption
End If
End Sub
Private Sub cmdVideoStream_Click()
'calls regimprt_b sub and imports the files into the registry
regimprt_b "Auto Accept Calls Disabled.reg"
regimprt_b "Auto Mix.reg"
regimprt_b "Calibrated Volume.reg"
end sub
Oh and I have tried & regfilename in the msgbox which shows which file is missing but i'ts not really a requirement.
Last edited by jbennett; Feb 13th, 2008 at 12:45 PM.
-
Feb 13th, 2008, 01:34 PM
#5
Re: Reg import issue
Change the sub to a function, so you can get a return value ...... and something like this:
vb Code:
Private Function regimprt_b(regfilename As String) As Boolean
If objFSO.FileExists("C:\Maintainer\Video Stream\Reg\" & regfilename) Then
wShell.Exec "regedit /s ""C:\Maintainer\Video Stream\Reg\" & regfilename
regimprt_b = True
Else
regimprt_b = False
End If
End Function
Private Sub cmdVideoStream_Click()
If regimprt_b("Auto Accept Calls Disabled.reg") = False Then GoTo msgError
If regimprt_b("Auto Mix.reg") = False Then GoTo msgError
If regimprt_b("Calibrated Volume.reg") = False Then GoTo msgError
MsgBox "passed", vbInformation + vbOKOnly, Me.Caption
Exit Sub
msgError:
MsgBox "File(s) missing within C:\Maintainer\Video Stream\Reg\", vbCritical + vbOKOnly, Me.Caption
Exit Sub
End Sub
-
Feb 13th, 2008, 02:52 PM
#6
Thread Starter
Addicted Member
Re: Reg import issue
Thanks again for your help,
I've actually found an easyier way of achieving this now.
I have cut out the regimprt stuff and just run wshell on the regedit /s ""C:\location\something\import.reg
I just merged all the reg files into one, therefore I can now refer to just the one file. Makes life so much easyier this way.
I do have 1 question regarding this though. I currently have the code checking if the 2 locations exist.
i'm wondering if its possible to check both locations seperately and display a msgbox with the location thats missing (if it is missing). Hope I make sense
-
Feb 13th, 2008, 02:52 PM
#7
Thread Starter
Addicted Member
Re: Reg import issue
oopppss forgot the code. Here it is: (and yes I have 2 different things going on here, 1 part is copying a file called Default.bps and the other part is importing the reg file)
Code:
Private Sub cmdBPFTPRepair_Click()
If objFSO.FileExists("C:\Maintainer\BPFTP\Default.bps") And objFSO.FolderExists("C:\Program Files\BPFTP\") Then
objFSO.CopyFile "C:\Maintainer\BPFTP\Default.bps", "C:\Program Files\BPFTP\Default.bps", OverwriteExisting
End If
If objFSO.FileExists("C:\Maintainer\BPFTP\Reg\bpftpImport.reg") Then
wshell.Exec "regedit /s ""C:\Maintainer\BPFTP\Reg\bpftpImport.reg"
MsgBox "Configuration Applied", vbInformation + vbOKOnly, Me.Caption
Else
MsgBox "Configuration Failed", vbCritical + vbOKOnly, Me.Caption
End If
End Sub
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
|