There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Auto switch/command in batch file


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
tigsboy's Avatar
Member with 88 posts.
 
Join Date: Nov 2001
Location: Oz
29-Jan-2004, 05:01 PM #1
Auto switch/command in batch file
We have a batch file that generates new users in W2K. When the file is run,the command window shows the share is created and the line:
"Command completed successfully" appears 4 times.
Then the line
" Are you sure (Y/N)" Appears.
This means we manually have to accept each new user.

Can anyone suggest and auto switch or command to automate the process.

Thanks in advance.

:: Script starts here
if "%4" == "" goto usage

:: Set Variables
setlocal
set username=%1
set fullname=%2 %3
set yearlevel=%4
set groupdir=Year%4
set userdir=E:\Students\%4\%username%
REM set skeldir=c:\Admin\%groupdir%
set loginscript=logon%6.bat
set password=%5
set pdc=\\default

:: Confirm account details
rem echo The current details for the account to be created are as follows:
rem echo.
rem echo username: %username%
rem echo fullname: %fullname%
rem echo yearlevel: %yearlevel%
rem echo userdir: %userdir%
REM echo skeldir: %skeldir%
rem echo loginscript: %loginscript%
rem echo password: %password%
rem echo pdc: %pdc%
rem echo.
rem echo Is this correct? Press Ctrl-C to abort or
rem pause

REM :: Error conditions (some very primitive)
rem Skeleton directory doesn't exist
REM if not exist %skeldir%\nul goto skeldirfail

rem Userdirectory already exists
if exist %userdir%\nul goto userdirfail

rem Group directory doesn't exist - you may want to remove this part.
REM ::if not exist c:\admin\%yearlevel%\nul goto groupdirfail

rem Check that there is a login.bat file
REM if not exist c:\winnt\system32\repl\import\scripts\%loginscript% goto loginscriptfail

:: Here is the fun stuff...
mkdir %userdir%
REM xcopy %skeldir% %userdir% /e /i /q /h
REM move %userdir%\base.bat %userdir%\%username%.bat
net share %username%$=%userdir% /users:4 /remark:"Home directory of %fullname%"
net user %username% %password% /fullname:"%fullname%" /homedir:%pdc%\%username%$ /profilepath:%LOGONSERVER%\PROFILES\yr%6.man /scriptpath:%loginscript% /time:M-F,06:00-18:00 /comment:"%yearlevel%" /add /domain
if errorlevel 1 goto create_error
net group "%yearlevel%" %username% /add /domain
net group "Students" %username% /add /domain
net group "Proxy_Student" %username% /add /domain
cacls %userdir% /t /g %username%:c "Domain Admins":f
echo Account created.
goto end

:usage
echo.
echo Adduser.bat - Add user to NT 4 domain
echo Usage: adduser username firstname surname Yearlevel Password YR(login.bat)
echo e.g. adduser fsmith Fred Smith Sales adg4a3(1 7
echo.
echo.
goto end
coderitr's Avatar
Distinguished Member with 3,080 posts.
 
Join Date: Oct 2003
29-Jan-2004, 08:26 PM #2
I'm guessing that the confirmation prompt is coming from the "net user" command. Have you tried /Y on that command? What I've seen with other "net ..." commands is that while undocumented in the /? help text, the /Y switch is an auto-confirmation.
tigsboy's Avatar
Member with 88 posts.
 
Join Date: Nov 2001
Location: Oz
29-Jan-2004, 08:44 PM #3
We found that when the confirmation command comes up in the dos window asking for a y/n, if we simply pressed enter, none of the security groups were entered, only the default EVERYONE. We assume that is because we were not actually accepting the CALCS command.
The same result happens if we append a /Y to the end of the calcs line, no security groups!
We have tried putting a /y right after the CALCS command but it tells us it is not a supported param of CALCS.

Thanks for the suggestion, any other hints.
tigsboy's Avatar
Member with 88 posts.
 
Join Date: Nov 2001
Location: Oz
29-Jan-2004, 11:33 PM #4
solved
Solved
It was simlpy a matter of changing to XCACLS from CACLS and adding the /y switch. Seems cacls doesn't support it and xcacls does.
Cheers
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:54 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.