none
Copying specific file from one pc to another RRS feed

  • General discussion

  • Hi, can I please get some help regarding this script, the intention is to copy file between remote PCs. Please let me know what you see wrong  

    Thanks 

    Set WshShell = WScript.CreateObject("WScript.Shell")
    If WScript.Arguments.Length = 0 Then
      Set ObjShell = CreateObject("Shell.Application")
      ObjShell.ShellExecute "wscript.exe" _
        , """" & WScript.ScriptFullName & """ RunAsAdministrator", , "runas", 1
      WScript.Quit
    End if

    Set oFSO = CreateObject("Scripting.FileSystemObject")
    set WSHShell = wscript.createObject("wscript.shell")

    Dim NewComputerName
    Dim OldComputerName     
    Dim DomainLoginID
    Dim Password

    DomainLoginID = "Domain\UserID" ' a login ID with admin permission for the machines to rename. In the Format of Domain\UserID
    Password = "UserPassword" ' the password for the user accoung

    OldComputerName = InputBox("Enter computers current name","Rename Computer Script")
    NewComputerName = InputBox("Enter computers new name","Rename Computer Script")

    DomainLoginID = InputBox("Enter user name","Domain Login Script")
    Password = InputBox("Enter password","password Script")

    Option Explicit

    ' The source path for the copy operation.
    Const strSourceFolder = "OldComputerName(c$\Program Files (x86)\PACSGEAR\PacsSCAN\Config\DefaultSettings.xml)"

    ' The target path for the copy operation.
    Const strTargetFolder = "NewComputerName(C:\Program Files (x86)\PACSGEAR\PacsSCAN\Config) "

    ' The source path for the copy operation.
    Const strSourceFolder = "OldComputerName(c$\Program Files (x86)\PACSGEAR\PacsSCAN\Config\DICOMSettings.xml)"

    ' The target path for the copy operation.
    Const strTargetFolder = "NewComputerName(C:\Program Files (x86)\PACSGEAR\PacsSCAN\Config) "

    ' The source path for the copy operation.
    Const strSourceFolder = "OldComputerName(c$\Program Files (x86)\PACSGEAR\PacsSCAN\Config\PaperSettings.xml)"

    ' The target path for the copy operation.
    Const strTargetFolder = "NewComputerName(C:\Program Files (x86)\PACSGEAR\PacsSCAN\Config) "


    Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Const ForReading = 1
    Dim objFileList
    Set objFileList = objFSO.OpenTextFile(strFileList, ForReading, False)

    Dim strFileToCopy, strSourceFilePath, strTargetFilePath
    On Error Resume Next
    Do Until objFileList.AtEndOfStream
        ' Read next line from file list and build filepaths
        strFileToCopy = objFileList.Readline
        strSourceFilePath = objFSO.BuildPath(strSourceFolder, strFileToCopy)
        strTargetFilePath = objFSO.BuildPath(strTargetFolder, strFileToCopy)

        ' Copy file to specified target folder.
        Err.Clear
        objFSO.CopyFile strSourceFilePath, strTargetFilePath, blnOverwrite
        If Err.Number = 0 Then
            ' File copied successfully

        Else
            ' Error copying file
            Wscript.Echo "Error " & Err.Number & " (" & Err.Description & "). Copying " & strFileToCopy
        End If
    Loop


    • Changed type Bill_Stewart Thursday, September 5, 2019 9:34 PM
    • Moved by Bill_Stewart Thursday, September 5, 2019 9:34 PM This is not "scripts on demand"
    Wednesday, June 5, 2019 6:17 PM

All replies