0

我目前在运行批处理文件时遇到这些错误:

System error 1379 has occurred.

The specified local group already exists.

Press any key to continue . . .
The system cannot find the file users.csv. {This is where my problem lies}
Press any key to continue . . .
There is no such global user or group: users.csv

我的批处理文件

@echo off

REM Adding a local group
net localgroup NEWDOSGROUP /Comment:"New Group Assignment" /add
pause
REM Add all the users from a .csv file

FOR /F "tokens=1,2 delims=," %%G IN (users.csv) DO (
    net adduser

pause
REM Adding users to a local group
FOR /F "tokens=1,2 delims=," %%a IN ("users.csv") Do (
    net localgroup NEWDOSGROUP %%a /add
    )
pause

任何帮助都会非常感谢。

4

2 回答 2

1

放在users.csv与批处理文件相同的文件夹中。

从外观上看,这个循环也缺少一个右括号,并且 net adduser 可能应该有一个 %%G 或 %%H 或类似的参数

FOR /F "tokens=1,2 delims=," %%G IN (users.csv) DO (
    net adduser
于 2013-10-07T03:29:27.307 回答
0
REM Add all the users from a .csv file

FOR /F "tokens=1,2 delims=," %%G IN (users.csv) DO (
    net adduser

REM ARE YOU MISSING A CLOSE-PARENTHESIS HERE?
REM WHAT IS NET ADDUSER?
REM WHY ARE YOU NOT USING %%G,%%H?
REM HERE YOU'VE OPENED USERS.CSV... ARE YOU THEN TRYING TO RE-OPEN IT?
REM IS AN OPEN USERS.CSV CAUSING THE PROBLEM?
REM IS THE SYNTAX OF THE FOR...%%a CORRECT? USEBACKQ PERHAPS?
REM NOT SHOUTING - JUST EMPHASISING

pause
REM Adding users to a local group
FOR /F "tokens=1,2 delims=," %%a IN ("users.csv") Do (
    net localgroup NEWDOSGROUP %%a /add
    )
pause
于 2013-12-02T01:55:57.403 回答