![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Oct 2006
Posts: 3
Rep Power: 0
![]() |
Hi guys! First time here nice to meet you all
I've had the unfortunate task of being forced to write windows batch file script (if could code this in bash or VB, i would have this task finshed in 2 minutes flat... -_-), It's a simple program really... but i can't make heads or tails of window's DOS commands documentations, the requirements below. 1 Run the net users command on a windows 2000 or XP computer. a) The script will then read the through the names generated by the program i. The script should ignore the following accounts:- Administrator ASPNET Guest HelpAssistant An account named SUPPORT_**** 2 Ask whether each account is to be deleted. a) If no, the program will go on to the next user b) If Yes, the script will delete the user account and i. Show the amount of space used in that user’s home directory. Assume that it is in the c:\documents and settings directory. Use the diruse command. Available on Kramer. ii. Ask whether the files must be deleted or left on disk. If the files are to be deleted, then the files are to be zipped up using the command line version of PKZip to be found on Kramer. And stored in a directory C:\BACKUP called old files under the user’s name. Use PKZIP iii. If the files are to be left on disk, then the files should be left on the disk but the ownership of the files must be changed to the Administrator. Use CACLS or XCACLS iv. Continue with the next user in the net users output 3 Your program should list the accounts that have been deleted, and those that have been left on disk. a) For accounts that have been deleted, list the users whose files have been stored in the C:\BACKUP directory 4 Make sure that you clean up any temporary or working files created in your script execution. |
|
|
|
|
|
#2 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Quote:
Perhaps you could show some code for your attempts.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,206
Rep Power: 5
![]() |
I think you're a little optimistic about your skills in bash or vb; a batch file script is just a program in another language. Essentially the command shell takes one command at a time and executes it. The format of a script file (more commonly known as a batch file, which is why it typically has a .BAT extension) is simply one line per command. The format of a batch file also has a few extensions which allow you to work with environment variables, local variables, command line arguments, and check return codes from programs executed by the batch file.
To get basic information (I'm using windows 2000 pro on my current machine, but the process will be similar for all versions of windows) go to Help option on the windows Start menu (Start->Help). Go to the "Index" tab, and type in "batch" and search. That will give you access to basic help provided by Microsoft. You can also start a command shell (Start->Program->Accessories->Command Prompt). That will pop up a command window. Type in "help" into that window and it will give a list of commands (you can type in "help | more" if you want to see information one screen at a time). Then "help <command>" to get help on particular commands. One thing to watch is that the command interpreter behaves a little differently between windows versions. The command interpreter under win 95/98/Me is similar to the older MS-DOS command interpreter, and is named "command". Under windows NT/2000/XP/2003 there are some slight differences in syntax, and the name of the interpreter is "cmd". That can be important in some circumstances that may not be relevant to your problem (eg if your batch file needs to launch another command interpreter). |
|
|
|
|
|
#4 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Shell scripting on Windows isn't as powerful as on *nix systems, partly due to the lack of small command line programs. Is it still a batch script if you just launch a VBScript file?
![]()
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Oct 2006
Posts: 3
Rep Power: 0
![]() |
Dameon, unfortunely it can't be coded as an VBScript... >.<
PS: DaWei: well... maybe not 2mins and probably not 10 minutes XD... What i really mean, is that I find the command lines tools (such as grep and the ease of piping some generated output through to another program etc) in linux much more user friendly and the manual pages for most of the commands very informative (e.g. give great examples) |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Oct 2006
Posts: 3
Rep Power: 0
![]() |
>.<... guys i'm stuck...
::Batch.bat net users>users.dat for /f "skip=4 tokens=1-3" %%a in (users.dat) do call c:\para.bat %%a & c:\para.bat %%b & c:\para.bat %%c :: para.bat @echo off if %1x == x goto end if %1 == The goto end if %1 == command goto end if %1 == completed goto end echo %1 :end |
|
|
|
|
|
#7 |
|
Programming Guru
![]() ![]() ![]() |
http://support.microsoft.com/kb/251394
http://www.microsoft.com/resources/d....mspx?mfr=true I'm curious as to why you cannot use something other than a batch file?
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| OnlineTextEditor.Com! | Sane | Show Off Your Open Source Projects | 43 | Jun 16th, 2006 8:55 AM |
| Command Prompt | SkyPioneer | Coder's Corner Lounge | 5 | May 3rd, 2006 10:07 PM |
| Backup Script :-) | Pizentios | Perl | 18 | Jan 12th, 2006 10:50 AM |
| After execution - Error cannot locate /Skin File? | wchar | Visual Basic | 1 | Mar 5th, 2005 9:04 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |