shell:Common Startup as a parameter to XCOPY

浪子不回头ぞ 提交于 2020-01-16 19:03:05

问题


I have a simple batch script that copies a file to the startup folder, but it appears that I can't use shell:Common Startup as a parameter to xcopy. I have tried this

xcopy hurrdurr.exe "shell:Common Startup"

and many other variations, and they don't work. As an aside, if this did work, "hurrdurr.exe" would run on every startup right, assuming I got clearance via uac to do the xcopy operation? Would using a environment variable be better? The os in question is Windows XP and proceeding.


回答1:


I'm not sure why your shell command won't work, but if you need to get your program to load on startup then I would much prefer using the registry, it's cleaner and simpler, and it means you don't have to copy the file somewhere else, especially if that file is dependant on other things.

reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "Hurrdurr" /d "hurrdurr.exe" /f

Just run cmd as admin and it will work :)

If you do want to use the startup folder though, on Win7 you can use

"%appdata%\Microsoft\Windows\Start Menu\Programs\Startup"

I would also use a shortcut as @David suggested instead of copying the actual file.



来源:https://stackoverflow.com/questions/13879384/shellcommon-startup-as-a-parameter-to-xcopy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!