mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 vb script to Copy file from Mapped Network share on Vista OS

Change Page: 12 > | Showing page 1 of 2, messages 1 to 20 of 24
Author Message
vvkalkundri

  • Total Posts : 12
  • Scores: 0
  • Reward points : 0
  • Joined: 10/30/2009
  • Status: offline
vb script to Copy file from Mapped Network share on Vista OS Sunday, January 31, 2010 6:17 PM (permalink)
0
 
Hi ,
 
I am using a simple script to copy the contents from a fileshare to the Local computer on Vista OS. Following is SCRIPT:
 
SourceFolder = "Z:\Builds\XVI_Int_2.0.15\"
CopyContents = "MMC_cd_code"
DestinationFolder = "C:\users\ABC\Builds\"
Set FSO = CreateObject("Scripting.FileSystemObject")
set WshShell = createobject("WScript.Shell")
 
 Set Source1 = FSO.GetFolder(SourceFolder)
 Set Source2 = Source1.SubFolders
 Set Source3 = Source1.Files
 
 
For Each s12 in Source3 
   if Instr(1,s12.Name,CopyContents,1) then 
       FSO.CopyFile SourceFolder + s12.Name, DestinationFolder
     End If
 Next
 
The script works fine on the XP os, but when i try to run the same on the Vista os, i get a error that says
"The Specified Network share is no Longer available"
Err Code : 80070040
 
How to address the same ?
 
Regards,
Vijay V K
#1
    rasimmer

    • Total Posts : 2360
    • Scores: 163
    • Reward points : 0
    • Joined: 3/19/2009
    • Location: Cedar Rapids, IA
    • Status: offline
    Re:vb script to Copy file from Mapped Network share on Vista OS Monday, February 01, 2010 4:48 AM (permalink)
    0
    Well, is the Z: mapped on the Vista machine?  Have you tried the UNC path vs the Z:?
    #2
      vvkalkundri

      • Total Posts : 12
      • Scores: 0
      • Reward points : 0
      • Joined: 10/30/2009
      • Status: offline
      Re:vb script to Copy file from Mapped Network share on Vista OS Monday, February 01, 2010 5:27 AM (permalink)
      0
      Z: is actually mapped to the UNC path.
      I have also tried to copy directly using the UNC path. It gives the same error.

      I see that the filesystemobject.CopyFile fails to do copy operation from the fileserver on a vista machine. Is there changes that have to be made to the script or is there any other approach that needs to be adopted ?
        The script works absoluely fine on XP32 bit and XP64 bit OS.
      #3
        rasimmer

        • Total Posts : 2360
        • Scores: 163
        • Reward points : 0
        • Joined: 3/19/2009
        • Location: Cedar Rapids, IA
        • Status: offline
        Re:vb script to Copy file from Mapped Network share on Vista OS Monday, February 01, 2010 5:31 AM (permalink)
        0
        What line is the error being generated on?   This one?

        FSO.CopyFile SourceFolder + s12.Name, DestinationFolder
         
        I'm surprised this is working.  It should have an ampersand, not  plus\addition sign
         
        FSO.CopyFile SourceFolder & s12.Name, DestinationFolder
        <message edited by rasimmer on Monday, February 01, 2010 5:33 AM>
        #4
          vvkalkundri

          • Total Posts : 12
          • Scores: 0
          • Reward points : 0
          • Joined: 10/30/2009
          • Status: offline
          Re:vb script to Copy file from Mapped Network share on Vista OS Monday, February 01, 2010 5:50 AM (permalink)
          0
          I am getting a error code : 80070040 and it says the Network path is not found.

          Actually there are around 5 files in the network share that have to be copied to the local m/c.
          When i give a message box, it gives the name of 1 st file and copy does not start , but it executes the second loop giving the name of the second file and that is also not copied, then in the 3rd iteration it gives the error message 80070040 Path Not found.
          #5
            rasimmer

            • Total Posts : 2360
            • Scores: 163
            • Reward points : 0
            • Joined: 3/19/2009
            • Location: Cedar Rapids, IA
            • Status: offline
            Re:vb script to Copy file from Mapped Network share on Vista OS Monday, February 01, 2010 7:08 AM (permalink)
            0
            So, if you do something like

            For Each s12 in Source3  
                If Instr(s12.Name, CopyContents) then  
                   WScript.Echo "Copying " & SourceFolder & s12.Name & " to " & DestinationFolder
                    'FSO.CopyFile SourceFolder + s12.Name, DestinationFolder 
                 End If
             Next
             
            Do you see the correct paths in the echo?
            #6
              faulkkev

              • Total Posts : 592
              • Scores: 13
              • Reward points : 0
              • Joined: 11/1/2005
              • Location: Kansas City, MO
              • Status: offline
              Re:vb script to Copy file from Mapped Network share on Vista OS Monday, February 01, 2010 9:56 AM (permalink)
              0
              can you manually get to the share or unc path? 
              #7
                vvkalkundri

                • Total Posts : 12
                • Scores: 0
                • Reward points : 0
                • Joined: 10/30/2009
                • Status: offline
                Re:vb script to Copy file from Mapped Network share on Vista OS Monday, February 01, 2010 3:16 PM (permalink)
                0
                rasimmer


                So, if you do something like

                For Each s12 in Source3  
                    If Instr(s12.Name, CopyContents) then  
                       WScript.Echo "Copying " & SourceFolder & s12.Name & " to " & DestinationFolder
                        'FSO.CopyFile SourceFolder + s12.Name, DestinationFolder 
                     End If
                 Next
                 
                Do you see the correct paths in the echo?


                       Yeah i do manually see the path in the Echo , for the ist 2 iteration, then the connection of the network is lost .
                and the files that are found in the 1st 2 iterations are not copied as well.


                <message edited by vvkalkundri on Monday, February 01, 2010 3:23 PM>
                #8
                  vvkalkundri

                  • Total Posts : 12
                  • Scores: 0
                  • Reward points : 0
                  • Joined: 10/30/2009
                  • Status: offline
                  Re:vb script to Copy file from Mapped Network share on Vista OS Monday, February 01, 2010 3:21 PM (permalink)
                  0
                  faulkkev


                  can you manually get to the share or unc path? 


                  Yeah i am manually able to copy the files from the Network share.
                  #9
                    Wakawaka

                    • Total Posts : 451
                    • Scores: 23
                    • Reward points : 0
                    • Joined: 8/27/2009
                    • Status: offline
                    Re:vb script to Copy file from Mapped Network share on Vista OS Monday, February 01, 2010 3:41 PM (permalink)
                    0
                    Try using the IsReady method of the FSO for the Z: drive.  Perhaps it will show it isn't ready for some reason and we can see if it is the code or the device?

                    dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject") 
                     dim strDrive : strDrive = "C:" 
                     
                     dim objDrive : Set objDrive = objFSO.GetDrive(strDrive) 
                     
                     If objDrive.IsReady Then 
                          WScript.Echo "The " & strDrive & " drive is accessible." 
                     Else 
                          WScript.Echo "The " & strDrive & " drive is inaccessible." 
                     End If 
                     
                     WScript.Quit 


                    If that doesn't work, perhaps we can have you put "On Error Resume Next" in there and have a echo showing every err.number to see if any are special at any point, other than the known one.
                    <message edited by Wakawaka on Monday, February 01, 2010 3:46 PM>
                    #10
                      vvkalkundri

                      • Total Posts : 12
                      • Scores: 0
                      • Reward points : 0
                      • Joined: 10/30/2009
                      • Status: offline
                      Re:vb script to Copy file from Mapped Network share on Vista OS Monday, February 01, 2010 4:47 PM (permalink)
                      0
                      Wakawaka


                      Try using the IsReady method of the FSO for the Z: drive.  Perhaps it will show it isn't ready for some reason and we can see if it is the code or the device?

                      dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")  
                       dim strDrive : strDrive = "C:"  
                       
                       dim objDrive : Set objDrive = objFSO.GetDrive(strDrive)  
                       
                       If objDrive.IsReady Then  
                           WScript.Echo "The " & strDrive & " drive is accessible."  
                       Else  
                           WScript.Echo "The " & strDrive & " drive is inaccessible."  
                       End If  
                       
                       WScript.Quit 


                      If that doesn't work, perhaps we can have you put "On Error Resume Next" in there and have a echo showing every err.number to see if any are special at any point, other than the known one.



                      If that doesn't work, perhaps we can have you put "On Error Resume Next" in there and have a echo showing every err.number to see if any are special at any point, other than the known one.




                      I have just checked the script, it says it is accessable. But when the Copy operation is going on it gets disconnected in between .
                      #11
                        Wakawaka

                        • Total Posts : 451
                        • Scores: 23
                        • Reward points : 0
                        • Joined: 8/27/2009
                        • Status: offline
                        Re:vb script to Copy file from Mapped Network share on Vista OS Tuesday, February 02, 2010 2:17 AM (permalink)
                        0
                        So you added that the IsReady method and it says it is accessible but then it says it is inaccessible or you are assuming that is what is happening?

                        Have you tried to loop the err numbers to see if any are different?
                        #12
                          vvkalkundri

                          • Total Posts : 12
                          • Scores: 0
                          • Reward points : 0
                          • Joined: 10/30/2009
                          • Status: offline
                          Re:vb script to Copy file from Mapped Network share on Vista OS Tuesday, February 02, 2010 5:06 AM (permalink)
                          0
                          Wakawaka


                          So you added that the IsReady method and it says it is accessible but then it says it is inaccessible or you are assuming that is what is happening?

                          Have you tried to loop the err numbers to see if any are different?



                          There is no error that is poped up when using the IsReady method. When i try to copy the contents there is a error code 80070040 that is poped up. This is only error message that i get when trying to copy.
                          #13
                            faulkkev

                            • Total Posts : 592
                            • Scores: 13
                            • Reward points : 0
                            • Joined: 11/1/2005
                            • Location: Kansas City, MO
                            • Status: offline
                            Re:vb script to Copy file from Mapped Network share on Vista OS Tuesday, February 02, 2010 8:38 AM (permalink)
                            0
                            Not sure maybe turn off the firewall if it is on or virus software.  make sure simple file sharing is disabled.
                            #14
                              vvkalkundri

                              • Total Posts : 12
                              • Scores: 0
                              • Reward points : 0
                              • Joined: 10/30/2009
                              • Status: offline
                              Re:vb script to Copy file from Mapped Network share on Vista OS Tuesday, February 02, 2010 6:47 PM (permalink)
                              0
                              faulkkev


                              Not sure maybe turn off the firewall if it is on or virus software.  make sure simple file sharing is disabled.


                              The firewall is turn off and there is no antivirus that is installed on the machine.
                              The simple file sharing is disabled.

                              Is there any other way/technique to copy from fileshare using VB Script in Vista OS ?


                              #15
                                Wakawaka

                                • Total Posts : 451
                                • Scores: 23
                                • Reward points : 0
                                • Joined: 8/27/2009
                                • Status: offline
                                Re:vb script to Copy file from Mapped Network share on Vista OS Wednesday, February 03, 2010 1:14 AM (permalink)
                                0
                                I don't know if this will work for you, but try it and let us know what happens.

                                Const SOURCE_FOLDER = "Z:\Builds\XVI_Int_2.0.15\"
                                 Const DESTINATION_FOLDER = "C:\users\ABC\Builds\" 
                                 Const SEARCH_STRING = "mmc_cd_code"
                                 
                                 Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
                                 
                                 If InStr(SOURCE_FOLDER, ":") Then
                                      Dim strDrive : strDrive = Left(SOURCE_FOLDER, 2)
                                      If objFSO.DriveExists(strDrive) Then
                                          Dim objDrive : Set objDrive = objFSO.GetDrive(strDrive)
                                      Else
                                          WScript.Echo strDrive & " drive does not exist."
                                      End If
                                 Else
                                      WScript.Echo SOURCE_FOLDER & "is not a valid folder path."
                                 End If
                                 
                                 Dim objFolder : Set objFolder = objFSO.GetFolder(SOURCE_FOLDER)
                                 
                                 For Each objFile In objFolder.Files
                                      If objDrive.IsReady Then
                                          If InStr(LCase(objFile.Name), SEARCH_STRING) Then
                                              objFSO.CopyFile objFile.Path, DESTINATION_FOLDER, True
                                          End If
                                      Else
                                          WScript.Echo strDrive & " is no longer accessible."
                                      End If
                                 Next
                                 
                                 WScript.Quit

                                #16
                                  drestauro

                                  • Total Posts : 4
                                  • Scores: 0
                                  • Reward points : 0
                                  • Joined: 3/9/2010
                                  • Status: offline
                                  Re:vb script to Copy file from Mapped Network share on Vista OS Tuesday, March 09, 2010 7:04 AM (permalink)
                                  0
                                  I'm having the same exact issue when my script copys from one network location to another.  The weird part about this is that  the script worked perfectly on Windows XP.  We put a new harddrive into the system and installed Vista on it and now we have the error that you mention ("The Specified Network share is no Longer available" Err Code : 80070040 ) when we run the same exact script. 
                                  #17
                                    pinkwho

                                    • Total Posts : 31
                                    • Scores: 2
                                    • Reward points : 0
                                    • Joined: 1/5/2010
                                    • Status: offline
                                    Re:vb script to Copy file from Mapped Network share on Vista OS Tuesday, March 09, 2010 7:44 AM (permalink)
                                    0
                                    drestauro


                                    I'm having the same exact issue when my script copys from one network location to another.  The weird part about this is that  the script worked perfectly on Windows XP.  We put a new harddrive into the system and installed Vista on it and now we have the error that you mention ("The Specified Network share is no Longer available" Err Code : 80070040 ) when we run the same exact script. 


                                    A few questions is the Vista OS patched to at least sp1?? The vista RTM was notoriously bad about file transfers (speed and otherwise).
                                    There may be something going on with the files and how they are opened / accessed at the OS level, I would run process monitor and process explorer from wininternals to "see" what may be happening.
                                    #18
                                      drestauro

                                      • Total Posts : 4
                                      • Scores: 0
                                      • Reward points : 0
                                      • Joined: 3/9/2010
                                      • Status: offline
                                      Re:vb script to Copy file from Mapped Network share on Vista OS Tuesday, March 09, 2010 8:57 AM (permalink)
                                      0
                                      Yes,  we have SP2 on the box.  I would love to run a process monitor on the box,  but I don't have the rights to do this,  so I'd have to convince someone else it would be a worthy endeavor.  I'm having a hard enough time convincing them it's not the script.
                                      #19
                                        drestauro

                                        • Total Posts : 4
                                        • Scores: 0
                                        • Reward points : 0
                                        • Joined: 3/9/2010
                                        • Status: offline
                                        Re:vb script to Copy file from Mapped Network share on Vista OS Wednesday, March 10, 2010 8:27 AM (permalink)
                                        0
                                        Okay,  I convinced someone to run a process monitor and it copies fine for awhile and then the mapped network drive drops.  The "WriteFile" operation just continually shows "DISCONNECTED"
                                        #20

                                          Online Bookmarks Sharing: Share/Bookmark
                                          Change Page: 12 > | Showing page 1 of 2, messages 1 to 20 of 24

                                          Jump to:

                                          Current active users

                                          There are 0 members and 1 guests.

                                          Icon Legend and Permission

                                          • New Messages
                                          • No New Messages
                                          • Hot Topic w/ New Messages
                                          • Hot Topic w/o New Messages
                                          • Locked w/ New Messages
                                          • Locked w/o New Messages
                                          • Read Message
                                          • Post New Thread
                                          • Reply to message
                                          • Post New Poll
                                          • Submit Vote
                                          • Post reward post
                                          • Delete my own posts
                                          • Delete my own threads
                                          • Rate post

                                          2000-2012 ASPPlayground.NET Forum Version 3.8
                                          mbt shoes www.wileywilson.com