简体   繁体   English

将另一个批处理文件复制到“启动”文件夹中?

[英]A batch file that copies another into Start Up folder?

I am making a batch file that needs to copy another batch file into the Start Menu Start Up folder (the one used when a program launches on login/start up) .我正在制作一个批处理文件,需要将另一个批处理文件复制到开始菜单启动文件夹(程序在登录/启动时启动时使用的文件夹) Since the path uses the user's computer name eg.由于路径使用用户的计算机名称,例如。 C:\Documents and Settings\User Name I need the batch file to get the user's correct name instead of the "User Name" or * (wildcard). C:\Documents and Settings\User Name我需要批处理文件来获取用户的正确名称,而不是“用户名”或* (通配符)。 Wildcards doesn't work as the batch file comes up with " the filename directory name or volume label syntax is incorrect ".通配符不起作用,因为批处理文件出现“文件名目录名称或卷 label 语法不正确”。

I hope this is clear enough.我希望这已经足够清楚了。

You can also try this:你也可以试试这个:

cd %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup

It works in Windows 10. The %appdata% variable gives you your required username by default它适用于 Windows 10。默认情况下, %appdata%变量为您提供所需的用户名

Open a new command prompt window by executing cmd.exe or using the shortcut in Accessories in Windows start menu.通过执行cmd.exe或使用 Windows 开始菜单中Accessories中的快捷方式打开一个新的命令提示符窗口。 Enter set and look on the list of environment variables predefined by Windows.输入set并查看 Windows 预定义的环境变量列表。 You are mostly interested in USERPROFILE .您最感兴趣的是USERPROFILE

The following command can be used to copy a batch file with name AaRM.bat from a folder available for all users like the all users desktop folder to startup folder of the currently logged in user.以下命令可用于将名为AaRM.bat的批处理文件从所有用户可用的文件夹(如所有用户桌面文件夹)复制到当前登录用户的启动文件夹。

copy "%ALLUSERSPROFILE%\Desktop\AaRM.bat" "%USERPROFILE%\Start Menu\Programs\Startup"

The double quotes are important as the name of the batch file with path and the path to the startup folder both contain spaces.双引号很重要,因为带有路径的批处理文件的名称和启动文件夹的路径都包含空格。

Copying the batch file from your desktop folder to the startup folder of the other user is most likely not possible as the other user might have no permission to access anything in your user profile directory and below.很可能无法将批处理文件从您的桌面文件夹复制到其他用户的启动文件夹,因为其他用户可能无权访问您的用户配置文件目录及以下的任何内容。

You can copy the batch file to distribute also to a different folder accessible for all users like "%ProgramFiles%" or %SystemRoot% as the batch file in all users desktop folder is visible for all user accounts on desktop.您可以复制批处理文件以分发到所有用户都可以访问的不同文件夹,如"%ProgramFiles%"%SystemRoot%因为所有用户桌面文件夹中的批处理文件对桌面上的所有用户帐户都是可见的。

Best would be to put the batch file into Windows directory ( %SystemRoot% or %windir% ) and create / copy a shortcut file (*.lnk) in / to startup folder of the other user accounts.最好将批处理文件放入 Windows 目录( %SystemRoot%%windir% )并在 / 中创建/复制一个快捷方式文件(*.lnk)到其他用户帐户的启动文件夹。 The Windows start menu folders should contain only *.lnk files and not batch files and applications. Windows 开始菜单文件夹应该只包含 *.lnk 文件,而不是批处理文件和应用程序。

And last it would be also possible to create a shortcut in "%ALLUSERSPROFILE%\\Start Menu\\Programs\\Startup" to the batch file in %windir% to execute this batch file for any user who logs in on this computer.最后,还可以在"%ALLUSERSPROFILE%\\Start Menu\\Programs\\Startup"创建一个快捷方式到%windir%中的批处理文件,以便为登录此计算机的任何用户执行此批处理文件。 Your batch file could contain at top something like if "%USERNAME%"=="your account name" goto :EOF 1 or more times with various user account names to prevent doing anything for 1 or more specific users.您的批处理文件可能在顶部包含类似if "%USERNAME%"=="your account name" goto :EOF 1 次或多次使用各种用户帐户名的内容,以防止为 1 个或多个特定用户执行任何操作。

try the following command if ur using win 7. never tried on win 8 though.如果您使用的是 win 7,请尝试以下命令。不过从未尝试过 win 8。

cd C:\\Users\\%username%\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup cd C:\\Users\\%username%\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup

works perfectly for me.非常适合我。

Stumped about nobody answering yet.. Why are we so lost?为没有人回答而难倒..为什么我们如此迷茫?

echo %userprofile%

To know the name of current user知道当前用户的名字

For copying Copy /y %~f0 "%USERPROFILE%\\%AppData%\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup用于复制Copy /y %~f0 "%USERPROFILE%\\%AppData%\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup

Alternative copy "path of file you want to copy" "path of the directory where you want it copied"替代副本“要复制的文件的路径”“要复制的目录的路径”

copy path of batch file path of startup folder启动文件夹的批处理文件路径的复制路径

Copy /y "File-Address-to-copy-here" "where-to-copy-to-here" Copy /y "File-Address-to-copy-here" "where-to-copy-to-here"
(as above) then save file as .bat and you have a batch file, run as admin if in system directories. (如上所述)然后将文件另存为 .bat 并且您有一个批处理文件,如果在系统目录中,请以管理员身份运行。

copy "C:\Documents and Settings\%username%\Desktop\batch.bat" "C:\Documents and Settings\%username%\Start Menu\Programs\Startup\"

这应该有效。

Try this:尝试这个:

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

Also, if you want to skip the username for the copy path, then use %username% instead of the actual username.此外,如果您想跳过复制路径的用户名,请使用%username%而不是实际用户名。

This works:这有效:

@echo off
copy "C:\Users\%username%\Desktop\somefolder\example.bat" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"

@echo off @回声关闭

copy "%~n0%~x0" "%USERPROFILE%\\Start Menu\\Programs\\Startup"复制 "%~n0%~x0" "%USERPROFILE%\\Start Menu\\Programs\\Startup"


* Use this code! *使用此代码!

i know the answer, type this in your batch file:我知道答案,请在您的批处理文件中输入:

copy "copy file path" "paste file path" copy "复制文件路径" "粘贴文件路径"

if the file path has a username than type %ALLUSERSPROFILE% instead of the username (it will fill up automatically the username for every windows pc)如果文件路径有一个用户名而不是输入 %ALLUSERSPROFILE% 而不是用户名(它会自动填写每个 windows pc 的用户名)

example: copy "C:\\Users%username%\\Desktop\\New folder\\hi.txt" "C:\\Users%username%\\Desktop"例如:复制“C:\\Users%username%\\Desktop\\New folder\\hi.txt”“C:\\Users%username%\\Desktop”

that did this: Example to what it did when opened这样做了:打开时的操作示例

final answer:最终答案:

copy "Path of file" "C:\\Users%username%\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup"复制“文件路径”“C:\\Users%username%\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup”

that would work那行得通

This should work:这应该工作:

copy "anything.bat" "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup"复制 "anything.bat" "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup"

this copies.txt, .exe, .bat, more into startup just change the.bat to anything else这个copys.txt, .exe, .bat, more into startup 只是把.bat改成别的

I made this in Windows 10我在 Windows 10 中制作了这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 批处理文件启动计算机 - Batch file start up a computer 批量 - 将以 pattern 开头的文件移动到某个文件夹 - Batch - Move file that start with pattern to a certain folder 创建批处理文件以备份指定的文件夹 - Creating a batch file to back up a specified folder 如何编辑BATCH启动命令以启动上述文件夹中的文件 - How to edit BATCH start command to start a file in folder above 使用批处理复制脚本复制文件仅将第一个文件复制到目标文件夹 - Copying files using Copy in batch script copies only the first file to the destination folder 如何制作批处理文件,将另一个批处理文件放入目标文件夹 - How to make a Batch file, that puts another batch file to a destination folder 如何使用另一个批处理文件中的变量启动Windows批处理文件 - How to start a windows batch file with variables from another batch file 批处理文件,不断检查文件夹中是否有新的CSV文件,将它们重命名,然后使用当前文件启动Firefox - Batch File to check Folder continuously for new CSV files , renaming them one after another and start Firefox with current File Windows批处理文件以提升的权限启动另一个批处理 - Windows batch file start another batch with elevated rights 使用批处理文件将文件夹的所有内容复制到另一个文件夹? - copying all contents of folder to another folder using batch file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM