請教,如何利用指令批次設定資源分享?



贊助商連結


bobhsieh
2012-06-28, 10:11 PM
net share tmp=c:\temp /grant:admin,full /cache:auto
這是將c:\temp,設定分享,其分享名稱為tmp,權限指定給admin

所以本想利用for指令,如下,將某個資料夾下的所有子資料夾,一次設定成分享狀態,
for %1 in (c:\tmp\*.* )do ( net share %1=%1 /grant:admin,full /cache:auto )

但是一直試不出來,

請問,有何方式可以透過批次方式,一次設定好資料分享?

贊助商連結


mis339
2012-06-28, 10:23 PM
那……直接把你所謂的「某個資料夾」分享出來不就好了?!

bx2aa
2012-06-29, 12:51 AM
net share tmp=c:\temp /grant:admin,full /cache:auto
這是將c:\temp,設定分享,其分享名稱為tmp,權限指定給admin

所以本想利用for指令,如下,將某個資料夾下的所有子資料夾,一次設定成分享狀態,
for %1 in (c:\tmp\*.* )do ( net share %1=%1 /grant:admin,full /cache:auto )

但是一直試不出來,

請問,有何方式可以透過批次方式,一次設定好資料分享?
如果你的命令沒錯的話
for %%i in (c:\tmp\*.* )do ( net share %%i=%%i /grant:admin,full /cache:auto )
放到 .bat .cmd 裏應該就沒問題了
%1 是你輸入命令那行的第一個參數

test.bat 內容輸入
@echo off
cls
echo %1


test 12345<Enter>
12345