Script to copy and paste a file on to a VBScr

July 30, 2011 at 20:48:36
Specs: Windows XP, 2.0 GHz, 512MB
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.


My Script.vbs

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



See More: Script to copy and paste a file on to a VBScr

Report •

#1
July 31, 2011 at 16:07:47
You could tell Windows to open .ext files with your VBScript. That assumes no other program opens .ext files, of course.

How To Ask Questions The Smart Way


Report •

#2
July 31, 2011 at 20:11:59
Thank you for the suggestion. I will definitely keep that in mind for future use.

However as I posted
"I have chosen these file names and directory paths to use as examples for my post. "

"File.ext" is just a name I invented to use as an example in my post. The actual file I copy is "buttonsoverlay.xul" and the various destination folders are the "custombuttons" folders in all my Firefox profile folders. I have "xul" files set to open
with a text editor. After thinking about it and realizing I don't open these files very often I think I will try out your suggestion. Do you think I need to convert the "vbs" file to an "exe" file? Thanks.


Report •

#3
July 31, 2011 at 23:41:48
To Razor2.3:

I had to convert the "vbs" file to an "exe" file and then IT WORKED.

Thanks for your suggestion I would have never thought of that.


Report •

Related Solutions

#4
August 1, 2011 at 01:28:17
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.

Report •

Ask Question