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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Head scratching "file not found" 2

Status
Not open for further replies.

thomasmcgeown

Technical User
Feb 6, 2002
27
GB
The following line of code is producing an error 53 file not found - app.path is E:\nettools and the file exists in e:\nettools\vncinstall\ ... any ideas?

runVNCexe = Shell("copy " & Chr$(34) & App.Path & "\vncinstall\winvnc.exe" & Chr$(34) & " " & Chr$(34) & strRemotePush & "winvnc.exe" & Chr$(34), vbNormalFocus)
 
At a guess strRemotePush doesn't end in "\"

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"Why does my program keep showing error messages every time something goes wrong?"
 
strRemotePush = "\\" & strSelected & "\C$\Program Files\RealVNC\WinVNC\"
- so not that!
 
i am domain admin and im testing it on my local machine, so its not permisions either..
 
Not sure what your problem is. Does this work?:
Code:
' Needs reference to Microsoft Scripting Runtime
  Dim fsoX As Scripting.FileSystemObject
  Dim strFrom As String
  Dim strTo As String
  
  Set fsoX = New Scripting.FileSystemObject
  strFrom = fsoX.BuildPath(App.Path, "\vncinstall\winvnc.exe")
  strTo = fsoX.BuildPath(strRemotePush, "winvnc.exe")
  fsoX.CopyFile strFrom, strTo
Hope this helps


Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"Why does my program keep showing error messages every time something goes wrong?"
 
ill give it a try, but i dont see why shell would need to reference the vb fso, a far as vb is concerned there just strings, no file access is done until shell takes over...

the command works fine if i run it manually from cmd
 
After your line of code put a message box

msgbox runVNCexe

Does the message box show the path you would expect?

Greg Palmer

----------------------------------------
Any feed back is appreciated.
 
it is blank, but that will be because it is unable to complete that line of code.. surely...
 
Sorry course remove the shell part

runVNCexe = "copy " & Chr$(34) & App.Path & "\vncinstall\winvnc.exe" & Chr$(34) & " " & Chr$(34) & strRemotePush & "winvnc.exe" & Chr$(34)

msgbox runVNCexe

Greg Palmer

----------------------------------------
Any feed back is appreciated.
 
returns correct paths for both source and destination as follows:

copy "e:\nettools\vncinstall\winvnc.exe" "\\tomm\c$\program files\realvnc\winvnc\winvnc.exe"

the above is also the exact line I use succesfully at a command prompt
 
Got it working, not an ideal solution by any means but did it by creating a batch file then running that from shell.. will slow my code down a hell of a lot when it has a list of machines to run the code on i think, never mind eh!

Set txtTryingBat = fso.createtextfile(App.Path & "\VNCInstall\trying.bat", 1)
txtTryingBat.WriteLine ("copy " & Chr$(34) & App.Path & "\vncinstall\winvnc.exe" & Chr$(34) & " " & Chr$(34) & strRemotePush & "winvnc.exe" & Chr$(34) & " /y")
txtTryingBat.Close
runVNCexe = Shell(App.Path & "\VNCInstall\trying.bat", vbNormalFocus)
 
I misread your original post, the problem is that visual basic cannot recognise the copy command from shell.

Try the following

Dim fso
Set fs = CreateObject("Scripting.FileSystemObject")
fs.copyfile Chr$(34) & App.Path & "\vncinstall\winvnc.exe" & Chr$(34), Chr$(34) & strRemotePush & "winvnc.exe" & Chr$(34)

Greg Palmer

----------------------------------------
Any feed back is appreciated.
 
Of course there's always:

FileCopy App.Path & "\VNCInstall\winvnc.exe", strRemotePush & "winvnc.exe"

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"Why does my program keep showing error messages every time something goes wrong?"
 
well that method works fine..

/me scratches his head some more

cheers all for your help!
 
I am assuming that e: is a mapped drive, is that correct?

Have you tried the full UNC path to the e: drive?

Why it should make a difference, i don't know, but it might!


Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
thomasmcgeown

Thanks for the star!

Out of curiousity does the FSO code I posted work on your system?

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"Why does my program keep showing error messages every time something goes wrong?"
 
matt king - no, e: is a local drive

andy watt- cant remember, i think not as i didnt use it as a solution - will try again to satisfy your curiosity :)
 
"I misread your original post, the problem is that visual basic cannot recognise the copy command from shell."

^^
does anyone have a list of commands that can and cant be sent to shell to save me this hassle in the future?!
 
'shell' will only recognise executables, ie .exe, .bat, .com so you can't really send any "commands" to it as such. Visual Basic has inbuilt functions such as name, move, kill, copyfile etc for doing this sort of thing, and at a more advanced level it has the fso which does the same things more professionally.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top