1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Script to copy and paste a file on to a VBScript file.

Discussion in 'Software Development' started by zappelectric19, Jul 31, 2011.

Thread Status:
Not open for further replies.
  1. zappelectric19

    zappelectric19 Thread Starter

    Joined:
    Aug 6, 2009
    Messages:
    10
    Does anyone know how to write a script that would specifically
    copy a file "File.ext" to the clipboard and paste it to this
    "My Script.vbs" file?

    I do not mean editing the VBScript file. I currently right click
    "File.ext" select "Copy" then right click "My Script.vbs" and
    select "Paste".

    I would like to know if I can do that with a script. I have included
    an example of the code used in "My Script.vbs" I have chosen these
    file names and directory paths to use as examples for my post.

    I thank you for reading this.

    My Script.vbs

    Code:
    On Error Resume Next
    Const OverwriteExisting = True
    Set objArgs = WScript.Arguments
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    If objArgs.Count < 1 Then
        WScript.Quit
    End If
    
    For I = 0 to objArgs.Count - 1
       Arg = objArgs(I)
    
       objFSO.CopyFile Arg, "C:\Desktop\", OverwriteExisting
       objFSO.CopyFile Arg, "D:\Desktop\", OverwriteExisting
       objFSO.CopyFile Arg, "E:\Desktop\", OverwriteExisting
       objFSO.CopyFile Arg, "F:\Desktop\", OverwriteExisting
       objFSO.CopyFile Arg, "G:\Desktop\", OverwriteExisting
    
       objFSO.CopyFolder Arg, "C:\Desktop\", OverwriteExisting
       objFSO.CopyFolder Arg, "D:\Desktop\", OverwriteExisting
       objFSO.CopyFolder Arg, "E:\Desktop\", OverwriteExisting
       objFSO.CopyFolder Arg, "F:\Desktop\", OverwriteExisting
       objFSO.CopyFolder Arg, "G:\Desktop\", OverwriteExisting
    
    Next
    WScript.Quit
     
  2. zappelectric19

    zappelectric19 Thread Starter

    Joined:
    Aug 6, 2009
    Messages:
    10
    This is what worked for me:
    I converted the vbs file to an exe file using ScriptCryptor.
    I use a script to open the file I want copied using that exe file.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1009977

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice