Jump to content

[SOLVED] Help with file copy from remote server


Recommended Posts

1 hour ago, Subz said:

Open CMD

Type: Net Use x: "\\192.168.20.13\Compartida\Publica" /USER:"domain.local\jaume" Password

 Does X: get mapped to the shared folder?

 

Yes! It appears on the local machine! That's amaizing!

Quote

Can you post the command you use here as well?

I don't understand this last sentence. D'you mean the code I have just typed in the cmd?

Can you post the command you use here as well?

Microsoft Windows [Versión 10.0.14393]
(c) 2016 Microsoft Corporation. Todos los derechos reservados.


C:\Users\Mantenimiento>Net Use x: "\\192.168.20.13\Compartida\Pública" /USER:"company.local\jaume" "XXXXX-XXXXX-XXXXX"
Se ha completado el comando correctamente.

 

Now it works like a charm. I can copy the desired file from the server to the local computer.

 

Thanks a lot for your help :huggles:

Edited by Qwerty212
Link to comment
Share on other sites

Glad to help, not sure if you have a full script but threw this together as I thought it might be helpful:

#NoTrayIcon

;~ Check to see if x: is mapped to '\\192.168.20.13\Compartida\Pública'
Global $sMAP_FILEPATH = DriveMapGet ('x:')
If @error Then ;~ Drive "x:" is not mapped to a shared path
    DriveMapAdd('x:', '\\192.168.20.13\Compartida\Pública', 1, 'company.local\jaume', 'Password') ;~ Map the drive to the server share
ElseIf $sMAP_FILEPATH <> '\\192.168.20.13\Compartida\Pública' Then ;~ Drive "x:" is mapped to a different path to "\\192.168.20.13\Compartida\Pública"
    DriveMapDel('x:')
    DriveMapAdd('x:', '\\192.168.20.13\Compartida\Pública', 1, 'company.local\jaume', 'Password') ;~ Map the drive to the server share
EndIf

$sSRC_FILEPATH = 'x:\PAULTAS' ;~ Source Folder Path - Do not include trailing backslash
    If FileExists($sSRC_FILEPATH) = 0 Then MAP_FILEPATH()
$sDST_FILEPATH = 'c:\PAULTAS' ;~ Destination Folder Path - Do not include trailing backslash
    If FileExists($sDST_FILEPATH) = 0 Then
        If DirCreate($sDST_FILEPATH) = 0 Then
            MsgBox(64, 'Create Destination Folder Error', 'Unable to create folder "' & $sDST_FILEPATH & '"')
            MAP_FILEPATH()
        EndIf
    EndIf

;~ Run Command: XCopy "x:\PAULTAS\*.pdf" "C:\PAULTAS" /D /E /C /R /H /I /K /Y
RunWait(@ComSpec & ' /c XCopy "' & $sSRC_FILEPATH & '\*.pdf" "' & $sDST_FILEPATH & '" /D /E /C /R /H /I /K /Y', '', @SW_HIDE)

MAP_FILEPATH()

Func MAP_FILEPATH()
    ;~ If your x: was mapped to another path, ask if you want to restore the old mapped drive
    If $sMAP_FILEPATH <> '\\192.168.20.13\Compartida\Pública' Then
        $iMSG_FILEPATH = MsgBox(36, 'Map Drive', 'Do you want to re map x: to "' & $sMAP_FILEPATH & '"?')
        If $iMSG_FILEPATH = 6 Then
            DriveMapDel('x:')
            DriveMapAdd('x:', $sMAP_FILEPATH) ;~ Map "x:" to the previous shared path
        EndIf
    EndIf
    Exit
EndFunc

 

Link to comment
Share on other sites

Hi Subz. The goal of the script was to print semi-filled pdf to our workers. Doing it I save them time writting manually the same data. The pdf are documents where they have to annotate the quality measuring they do each our of our prodcuts.

 

Due to the quality control requirements they have to fill some data like the raw material suplier, the current day or the batch number. I have reused an already script that uses a webcam as qr barcode reader. We use this script to get another kind of documents filled (the ones that you have to use to identify each box of our products).

I really don't care about if the drive is mapped to x:. I have included an If statement, so if someday the drive is not mapped as x: it would mean that there is some kind of problem but I really appreciate the script above. It can be really helpfull for someone that comes looking for help with a similar issue.

 

Greets from Barcelona

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...