locked
copy a exe file using sms2003. RRS feed

  • Question

  • Hi All,

    I want to copy winword.exe stored in sms server to all other client pc's in my corporate,can any one let me know how i can copy this.

    I used xcopy.exe e:\filecpy c:\filecpy command line through sms, but unable to acheive

    Anyone can guide me, where to start and how can i do this

     


    Best regards Lokesh Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
    Monday, January 10, 2011 10:15 AM

Answers

  • Try this Script:

    on Error Resume Next
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set objinputfile=fso.OpenTextFile("computers.txt",1,True)
    Set objoutputfile=fso.OpenTextFile("status.csv",2,True)
    Do While objinputfile.AtEndOfLine <> True
           strcomputer=objinputfile.ReadLine
     Set objWMIService = GetObject("winmgmts:\\" & strComputer)
        If Err.Number <> 0 Then
            objoutputfile.WriteLine(strcomputer & space(15-len(strcomputer)) & "is not reachable")
            Err.Clear
            Else
    strFileName = "D:\FileName.Txt"
    Const OverwriteExisting = True
    FSO.CopyFile strFileName, "\\" & strComputer & "\C$\"
    objoutputfile.WriteLine (strcomputer & "," & space(15-len(strcomputer)) & "File Copy done")
    End If
    Loop
    MsgBox "Done"

    Bold Letters requires modifications.

    You can also copy the files using psexec tool as given above.


    //Eswar Koneti @ http://eskonr.com/
    • Marked as answer by lokeshbabu Tuesday, February 1, 2011 10:57 AM
    Tuesday, January 18, 2011 12:18 PM
  • Hi Eswar,

    This worked for me, thanks a lot.


    Best regards Lokesh
    • Marked as answer by lokeshbabu Tuesday, February 1, 2011 11:32 AM
    Tuesday, February 1, 2011 10:56 AM

All replies

  • Hi Lokesh,

    You could create the following batch file and advertise it to your client to copy the winword.exe file.

     

    copy "%~dp0winword.exe" c:\destfolder\

    Please keep winword.exe in the same folder where you kept your .bat file. "Destfolder" is the folder were you want to copy it on the target computer.

    BTW, why you want to copy only winword.exe?

     


    Regards, Madan | www.madanmohan.com
    Monday, January 10, 2011 11:28 AM
  • You can use the below Bat script to copy file to list of computers supplied by notepad.txt

    Create a notpad and save as .bat with below commands.

    @Echo Off

    REM Files copying to remote System

    FOR /F  %%c IN (D:\Copy_files\computers.txt) Do (XCopy D:\script\winword.exe \\%%c\C$\temp\
    )
    Echo Files copied.
    Pause
    Exit

    Create computers.txt and add the computers to it whcih will be placed in D:\copy_files and temp is folder where file is copied to.

     

     


    //Eswar Koneti @ http://eskonr.com/
    • Proposed as answer by Eswar konetiMVP Wednesday, January 12, 2011 5:34 AM
    Tuesday, January 11, 2011 1:22 PM
  • Hi Eswar,

    Can you modify this script for me to get a list of computers from notepad, copy the file and report the sucess event in an excel file

    strComputer = InputBox ("Enter Machine Name")
    strFileName = "C:\IE7-WindowsXP-x86-enu.exe"
    Const OverwriteExisting = True
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.CopyFile strFileName, "\\" & strComputer & "\C$\"
    MsgBox "Done"

    Thanks in advance.


    Best regards Lokesh Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
    Thursday, January 13, 2011 10:21 AM
  • Try this Script:

    on Error Resume Next
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set objinputfile=fso.OpenTextFile("computers.txt",1,True)
    Set objoutputfile=fso.OpenTextFile("status.csv",2,True)
    Do While objinputfile.AtEndOfLine <> True
           strcomputer=objinputfile.ReadLine
     Set objWMIService = GetObject("winmgmts:\\" & strComputer)
        If Err.Number <> 0 Then
            objoutputfile.WriteLine(strcomputer & space(15-len(strcomputer)) & "is not reachable")
            Err.Clear
            Else
    strFileName = "D:\FileName.Txt"
    Const OverwriteExisting = True
    FSO.CopyFile strFileName, "\\" & strComputer & "\C$\"
    objoutputfile.WriteLine (strcomputer & "," & space(15-len(strcomputer)) & "File Copy done")
    End If
    Loop
    MsgBox "Done"

    Bold Letters requires modifications.

    You can also copy the files using psexec tool as given above.


    //Eswar Koneti @ http://eskonr.com/
    • Marked as answer by lokeshbabu Tuesday, February 1, 2011 10:57 AM
    Tuesday, January 18, 2011 12:18 PM
  • Hi Eswar, thankyou for your reply.

    But when i run this script, it shows as file copy done in the output file and no file is copied in the destination. Can you help me

    Thanks in advance.

     


    Best regards Lokesh Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
    Tuesday, February 1, 2011 8:08 AM
  • the posted script is working fine for me without any issues .

    Can you post the script which you are using ? (suppose to be the same.)


    //Eswar Koneti @ www.eskonr.com
    Tuesday, February 1, 2011 9:52 AM
  • Hello - Why don't you use the method mentioned by Madan?
    Anoop C Nair
    Tuesday, February 1, 2011 10:26 AM
  • Hi Eswar,

    This worked for me, thanks a lot.


    Best regards Lokesh
    • Marked as answer by lokeshbabu Tuesday, February 1, 2011 11:32 AM
    Tuesday, February 1, 2011 10:56 AM