# WINDOWS批处理应用2
# 禁封U口
该选项值是十六进制的3
@echo off
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t reg_dword /d 4 /f
pause
1
2
3
2
3
# 添加共享盘
@echo off
set NasAddr="\\10.0.1.1\shared"
set TargetDrive="z:"
set UserName="user"
set Password="123456"
net use %TargetDrive% /delete
net use %TargetDrive% %NasAddr% /Persistent:yes /user:%UserName% %Password%
pause
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 映射目标文件夹
将当前文件夹映射到某个目标文件夹里面
@echo off
set targetFolder="C:\Program Files\Epic Games"
::————————以下为脚本————————————
@echo 当前运行目录:%cd%
@echo 脚本所在目录:%~dp0
set currentFolder=%~dp0
set sourceFolder=%~dp0
set currentFolder=%currentFolder:~,-1%
set currentFolder=%currentFolder:\= %
for %%a in (%currentFolder%) do (
set currentFolderName=%%a
)
if not exist %targetFolder% (
echo 不存在该文件夹,创建了该文件夹!
mkdir %targetFolder%
attrib -R %targetFolder% /S
takeown /f %targetFolder%
)else (
echo 存在该文件夹,即将创建快捷方式!
)
set targetFolder=%targetFolder%\"%CurrentFolderName%"
mklink /j %targetFolder% %sourceFolder%
pause
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 用户相关操作
删除用户
net user UserName /del
激活用户
net user UserName /active:yes
添加用户
net user UserName Password /add
显示当前administrators组成员
net localgroup administrators
添加用户到administrators组
net localgroup administrators UserName /add