-2

I've been typing a simple script, but i need it to copy itself into the startup folder. However,the path to the folder has spaces in it, and i've tried quoting it and double quoting, but nothing has worked. What's wrong with this script?

FileSystemObject.CopyFile "C:\Documents and Settings\keemstar\Desktop\dolpo.vbs", """C:\Documents and Settings"\keemstar\Start Menu\Programs\Startup" 

NOTE that this isnt final, as it's been edited many times. I'm not even sure if this is the right command, but sources say it is. I know this is a stupid question, but I'd love it if someone could help.

dolphin
  • 19
  • 1
  • 4

2 Answers2

1

In my experience, copying files using the CopyFile function of FileSystemObject has led to mixed results.

Whenever I need to copy files using VBScript, I usually opt for running the Windows copy-command instead:

set wshShell  = CreateObject("Wscript.Shell")

sSourceFile   = "C:\Documents and Settings\keemstar\Desktop\dolpo.vbs"
sTargetFolder = "C:\Documents and Settings\keemstar\Start Menu\Programs\Startup"

sCmd = "%comspec% /c copy """ & sSourceFile & """ """ & sTargetFolder & """ /Y"

wshShell.Run sCmd, 0, True
Drasen
  • 61
  • 4
0

Try to use Shell.Application instead of FSO:

CreateObject("Shell.Application").Namespace(7).CopyHere WScript.ScriptFullName, 4 + 16 + 1024
omegastripes
  • 12,351
  • 4
  • 45
  • 96