我目前正在制作一些代码,将本地用户添加到群组中,而且我很困难。执行这六行时会出现问题:
if /I "%choix%"=="1" do net localgroup %grp1% %%A /add
if /I "%choix%"=="2" do net localgroup %grp2% %%A /add
if /I "%choix%"=="3" do (
net localgroup %grp1% %%A /add
net localgroup %grp2% %%A /add
)
这是我的完整代码:
@ echo off
:debut
set /P fichiercsv="Complete file path :"
set /P grp1="Enter the first group name :"
set /P grp2="Enter the second group name :"
net localgroup %grp1% /add
net localgroup %grp2% /add
for /F "eol=; tokens=1,2 delims=," %%A in (%fichiercsv%) do net user %%A %%B /add
pause
for /F "eol=; tokens=1,2 delims=," %%A in (%fichiercsv%) do (
cls
echo In which group do you want to add %%A?
echo 1. %grp1%
echo 2. %grp2%
echo 3. %grp1% et %grp2%
set /P choix="Enter a number : "
if /I "%choix%"=="1" do net localgroup %grp1% %%A /add
if /I "%choix%"=="2" do net localgroup %grp2% %%A /add
if /I "%choix%"=="3" do (
net localgroup %grp1% %%A /add
net localgroup %grp2% %%A /add
)
)
echo All users where added to the groups
echo Do you want to specify another file ?
set /P continuer="continue whit another csv file [o/n] ?"
if /I "%continuer%" EQU "o" goto debut
if /I "%continuer%" EQU "n" goto fin
:fin
echo Resultat final:
type %fichiercsv%
echo Au revoir !