Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Software Development Software Development
Search Search
Search for:
Tech Support Guy > > >

VB Script to Run a Batch File and Utilize a Text File


(!)

ncktravis's Avatar
ncktravis ncktravis is offline
Member with 11 posts.
THREAD STARTER
 
Join Date: Aug 2012
Experience: Intermediate
10-Aug-2012, 01:03 PM #1
Post VB Script to Run a Batch File and Utilize a Text File
Backround: I am a college student majoring in Information Technology with a focus in programming. I also work for my school's IT department as an IT associate. I have 4 years of experience dealing with hardware and software and have studied Net+ and A+ certification books.

Problem: At my school my boss, the IT Director, wants to schedule a batch file to run weekly that will delete items from the desktop and folders of the "Student" account on all of the student computers. He asked us associates to go around to every student computer with this batch file on a thumb drive and schedule the task. Seems simple enough right? The problem is we are talking upwards of 300 computers throughout the campus. I proposed a solution to him where we would use a script that would essentially consult a text document with the names of all of the student computers in it, then run the file.

I am 99% this can be done, I just have a very small amount of programming experience. If anyone has an answer or knows of an easier way to accomplish this I appreciate it. Thanks in advance.

EDIT: All student workstations are running Windows XP SP2

Last edited by ncktravis; 10-Aug-2012 at 01:11 PM.. Reason: workstation
Ent's Avatar
Ent   (Josiah) Ent is offline Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,274 posts.
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
10-Aug-2012, 01:49 PM #2
By the sound of it it could be done; the question is whether it's the best way of doing it.
1: How do you propose to get these computers to execute the VBS? Taking it round on a flash drive isn't a great improvement .


Other questions about your scheme:
Why use both batch and VBS instead of just one or the other? (worst case scenario VBS can simply execute each of the shell commands in the batch file.)
How involved do you want to be in writing the script?
ncktravis's Avatar
ncktravis ncktravis is offline
Member with 11 posts.
THREAD STARTER
 
Join Date: Aug 2012
Experience: Intermediate
10-Aug-2012, 02:39 PM #3
I'm almost certain there is an automated way to get this job done, like you said perhaps using a batch file or script isn't the best way and Bill Gates has an easier way to do it built into MS Server.

I've been searching through countless web sites and trying to research and the conclusion I came to is a VBS may be the least painstaking way of going about this. I actually just recently came upon a thread on another site where someone was looking to shutdown every computer on their domain with a few clicks using a shutdown batch. Similar situation, just a different end result. We already have the simple batch file, I wasn't sure if it could just be edited to run on all of the workstations named in a text file or if I would have to use a VBS for that. As far as how involved I'd like to get in writing this script, I've done simple programming, and this is a simple objective. So I'm hoping it won't have to be too involved, but I'm not afraid to get my hands dirty so to speak.
ckphilli's Avatar
ckphilli   (Chris) ckphilli is offline
Member with 4,294 posts.
 
Join Date: Apr 2006
Location: Down South
Experience: Intermediate
10-Aug-2012, 04:00 PM #4
If all user accounts are named 'student' and all are XP...why not write the bat to execute from any machine on the network with proper credentials...like so (as an example)...

del \\computer1\c$\documents and settings\student\desktop\*.*
del \\computer2\c$\documents and settings\student\desktop\*.*
del \\computer3\c$\documents and settings\student\desktop\*.*

...

And then schedule it.

Of course this assumes that the 300 are on the same network and that you have the proper credentials. Obviously, you'll want to test...
Ent's Avatar
Ent   (Josiah) Ent is offline Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,274 posts.
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
10-Aug-2012, 04:04 PM #5
It's impossible to give specific advice without knowing how the network is actually set up.
I would imagine that students are in a specific group for security policies et cetera, and I would therefore imagine that you could ignore the whole text file stage and just put some extra lines on the end of the logon script that I imagine members of said group already run.

Incidentally, I love writing scripts and programs, but in the real world there can be a time when it's genuinely not worth it. In terms of time alone the time taken to design, test, and deploy an automated solution could be longer than getting a bunch of guys to wander round the school with USB sticks. In terms of experience writing software would do you a lot more good than plugging in flash drives, which is why it probably is in your interest to get your hands dirty.
ncktravis's Avatar
ncktravis ncktravis is offline
Member with 11 posts.
THREAD STARTER
 
Join Date: Aug 2012
Experience: Intermediate
10-Aug-2012, 04:33 PM #6
@Chris I think that should do it, I didn't even think of that. Of course it will have to be run with administrative credentials, which I have. Every computer is connected to the same network, and doing it that way I can easily exclude staff computers.

@Josiah That is very true, programming is definitely what my concentration is, and I wouldn't mind, in fact would love to get my hands dirty. I knew it could be automated in some way, somehow.

As far as I'm concerned I think I've got my solution. Time to go test it out.

Cheers
Ent's Avatar
Ent   (Josiah) Ent is offline Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,274 posts.
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
10-Aug-2012, 04:43 PM #7
Remember that you have to test your solution in all the situations it could encounter.
The last thing you want is that it fails on one line (because a computer has been shut down for example) and then exits instead of doing the rest of the script.

Also, use a loop.
ncktravis's Avatar
ncktravis ncktravis is offline
Member with 11 posts.
THREAD STARTER
 
Join Date: Aug 2012
Experience: Intermediate
10-Aug-2012, 04:55 PM #8
Right, I could set it to ping each target computer, and if found online it would then delete the files, if not, well then it wouldn't?

Or would a computer being offline even have an effect on the process? Other than the fact that that computer or computers wouldn't have their items being deleted?
Ent's Avatar
Ent   (Josiah) Ent is offline Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,274 posts.
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
10-Aug-2012, 04:58 PM #9
That's one good check. You really do have to think about what kinds of situations you'll encounter.
Another possible problem I'd foresee is the possibility that a file is still in use and/or locked.
ckphilli's Avatar
ckphilli   (Chris) ckphilli is offline
Member with 4,294 posts.
 
Join Date: Apr 2006
Location: Down South
Experience: Intermediate
10-Aug-2012, 05:01 PM #10
Yes! Error handling is a must. I wouldn't ping though, just write something for if the path is not found. Also, I would log what's being deleted for trends analysis (security, productivity, etc). Don't forget to have fun also.
ncktravis's Avatar
ncktravis ncktravis is offline
Member with 11 posts.
THREAD STARTER
 
Join Date: Aug 2012
Experience: Intermediate
10-Aug-2012, 05:04 PM #11
That is also true, it'll definitely be an all day affair if not longer. But once completed, and tested/tweaked to function properly it will be simple to add/del computers from the bat. For example if the school receives a new shipment of workstations it is much faster to edit a file than to individually schedule a task.
ncktravis's Avatar
ncktravis ncktravis is offline
Member with 11 posts.
THREAD STARTER
 
Join Date: Aug 2012
Experience: Intermediate
10-Aug-2012, 05:05 PM #12
@Chris Could I get an example of what that would look like including the loop, etc?
ckphilli's Avatar
ckphilli   (Chris) ckphilli is offline
Member with 4,294 posts.
 
Join Date: Apr 2006
Location: Down South
Experience: Intermediate
10-Aug-2012, 05:09 PM #13
I'm actually on my phone waiting for a meeting, sorry. But if you haven't gotten it by tomorrow or if Ent doesn't do it I'll put something up for you.
ncktravis's Avatar
ncktravis ncktravis is offline
Member with 11 posts.
THREAD STARTER
 
Join Date: Aug 2012
Experience: Intermediate
10-Aug-2012, 05:09 PM #14
I'm attempting to work this out myself, but if I had something to check against it would make my night a tad easier.
ncktravis's Avatar
ncktravis ncktravis is offline
Member with 11 posts.
THREAD STARTER
 
Join Date: Aug 2012
Experience: Intermediate
10-Aug-2012, 05:11 PM #15
Not a problem, I'm going to see what I can do. Here's to a night of trial and error.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




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


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑