iT邦幫忙

0

WINDOW共用問題

  • 分享至 

  • xImage

請問想用bat檔將"公用資料夾共用"開啟並且將"以密碼保護的共用"關閉,請問指令要如何撰寫?

perry168 iT邦新手 1 級 ‧ 2024-12-26 18:14:08 檢舉
試試
md C:\SharedFolder
net share SharedFolder=C:\SharedFolder /GRANT:EVERYONE,FULL
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
zivzhong
iT邦研究生 2 級 ‧ 2024-12-27 10:46:15

試試:
@echo off
REM 確認以管理員身份執行
net session >nul 2>&1
if %errorLevel% neq 0 (
echo 請以管理員身份執行此批次檔。
pause
exit
)

REM 開啟公用資料夾共用
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SharingOptions" /v "AllUsersShare" /t REG_DWORD /d 1 /f

REM 關閉以密碼保護的共用
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SharingOptions" /v "PasswordProtectedSharing" /t REG_DWORD /d 0 /f

REM 重新啟動「Server」服務以套用變更
echo 正在重新啟動「Server」服務...
net stop server
net start server

echo 設定已完成。
pause

wdeath iT邦新手 5 級 ‧ 2024-12-30 09:48:34 檢舉

https://ithelp.ithome.com.tw/upload/images/20241230/201711834pQpqn9zJW.pnghttps://ithelp.ithome.com.tw/upload/images/20241230/20171183uHoHb9riaK.pnghttps://ithelp.ithome.com.tw/upload/images/20241230/20171183EzMwZC1Tqk.png
感謝你的回答,執行後檢查機碼有變更但設定畫面一樣沒有動作,也重開機試過。

我要發表回答

立即登入回答