0
votes

I'm trying to make a vbs script to set an application to run on windows startup, but it seems not to work... here's the code:

set WshShell = CreateObject("Wscript.Shell")
set fs = CreateObject("Scripting.FilesystemObject")
pathe = WshShell.SpecialFolders("Startup")
start()
function start()
x = fs.CopyFile("hello.bat", Path & "\", True)
end function
wscript.echo(Path)

if you know any other method to set a file to run on startup it is good

1
Replace pathe with path. Also remove the lines function start() and end function. - omegastripes
Why would you be copying a batch file to the start-up directory, in order to make it run on every startup, but then invoking that copy process by running a vbscript on every startup. The idea is ill thought out, or intended malicious behavior. Why not just start the batch file in its current location, as a scheduled task, and exclude the vbscript completely? - Compo

1 Answers

0
votes

Try this, just a one liner can do this:

CreateObject("Shell.Application").NameSpace(7).CopyHere "hello.bat", 4 + 16 + 1024 : Wscript.Echo "hello.bat"