标题: 批处理共享多盘符
[打印本页]
作者: iamqiuhui
时间: 2010-1-31 13:22
标题: 批处理共享多盘符
C:\Documents and Settings\Administrator>for /f "usebackq" %S in ("c:\Documents a
nd Settings\Administrator\桌面\disk.txt") do net share %S=%S:
桌面上放个disk.txt文本文件,
内容如下:
e
f
g
h
i
j
k
l
这样可以,共享名如果和卷标同名,就完美了,
那位仁兄补充一下:
作者: iamqiuhui
时间: 2010-2-3 14:12
标题: top
@echo off
title 正在启用e-l盘共享**************
rem 记取盘符字母 %%d
rem 延迟变量,使外部errorlevel不影响内部errorlevel
setlocal enabledelayedexpansion
for /f "" %%d in (d:\mydocs\disk.txt) do (
echo %%d
vol %%d: | find "驱动器" >c:\%%d.txt
rem 读取vol名称作为共享名 %%n
for /f "tokens=4" %%n in (c:\%%d.txt) do (
echo %%n
echo %%n | find "+" >nul
echo !errorlevel!
if !errorlevel!==0 (net share %%d=%%d:\) else (net share %%n=%%d:\)
)
)
echo 共享成功
echo powered by qiuhui 2010-1-31 in sytwb
ping 1 -n 1 -w 5000 >nul
rem
rem vol %%d: | find "驱动器" >c:\%%d.txt
rem for /f "tokens=4" %%n in (c:\%%d.txt) do (echo %%n
rem net share %%n=%%d:\
rem )
这样就好一些了,可以用卷标名称做共享名,清晰多了