[RESOLVED] Problem with CopyFile - Error 9
So I'm making a VNC push program and I'm having problems with the Copying of the files. I keep getting error #9 and I cannot figure out why.
I am logging into the computer using the WNetAddConnection2 API first:
Code:
con = WNetAddConnection2(networkResource, WindowsPass, WindowsUser, 0)
I get a return of '0' for con, and I have seen '75', '53' before so I know the API login works now. As for my CopyFile calls:
Code:
'Variable's I'm Passing In'
'Source = "C:\fastpush\real412"
'remoteFinalPath = "\\<machine name>\C$\Program Files\RealVNC\VNC4"
Code:
Call CopyFile(Source & "\logmessages.dll", remoteFinalPath & "\logmessages.dll", 0)
Call CopyFile(Source & "\vncconfig.exe", remoteFinalPath & "\vncconfig.exe", 0)
Call CopyFile(Source & "\vncviewer.exe", remoteFinalPath & "\vncviewer.exe", 0)
Call CopyFile(Source & "\winvnc4.exe", remoteFinalPath & "\winvnc4.exe", 0)
Call CopyFile(Source & "\wm_hooks.dll", remoteFinalPath & "\wm_hooks.dll", 0)
Call CopyFile(Source & "\REGINI.EXE", remoteFinalPath & "\REGINI.EXE", 0)
Call CopyFile(Source & "\vnc4.ini", remoteFinalPath & "\vnc4.ini", 0)
Call CopyFile(Source & "\machine.ini", remoteFinalPath & "\machine.ini", 0)
Any ideas as to what is happening? I can browse to the remote path using the windows run box as I have it typed above...as I have read error 9 is a subscript out of range and I tried a full compile with the IDE no dice.
Re: Problem with CopyFile - Error 9
Closing I double checked and I missed spelled a variable that was passed in so the source path was all wrong.
Re: [RESOLVED] Problem with CopyFile - Error 9
You can stop that happening again by simply adding Option Explicit to the top of your code (it will give you an obvious error if you mis-spell a variable name!).
For more information (including how to make it happen automatically for any new code files you create), see the article What is Option Explicit, and why should I use it? from our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)
Re: [RESOLVED] Problem with CopyFile - Error 9
Well I didn't explain it as well as I should have but it was 2am ;-). I had the source path passed in using a ByVal and at one point where it was being passed an old variable from an earlier build was left over that defined the path but it was blank, hence the issue. Thanks though, I always have option explicit on ;-)