Jump to content

Recommended Posts

Posted

is there any speed benefit that i can gain by converting my login batch files to vbs if so where can i get some good syntax examples for mapping drives, printers based on location etc.

I have a fairly good grasp on batch file syntax but none at all on many other scripting launguages.

Posted

If you have a look at the stick theres a few scriptomatics and such that will give you examples.

You arent going to notice any performance increase/decrease I would have said.

At the end of the day it depends how complex you login script is. Alot of the time you can do the same thing with one line of a batch scipt than three lines of VBS.

There are ofc more complicated things you can do with VBS though.

Posted

uraken - it's worth getting familiar with vbscript; there's so much you can't easily do with batch files (and when you can do it, no-one else will understand it :-))

 

For example, there's been discussion about recording user logons and examples of how to do this with a batch file creating a text logfile. This can work on a small scale but it doesn't scale well and reporting on it is hard work. If you use vbscript then you can log the data directly to a SQL database (SQL 2005 Express is free and more than adequate) which you can then report from easily (we use .asp pages so that anyone can quickly find stuff)

Posted

I think the FOR / command is an area where bat/cmd wins over VBS.

 

In VBS there's no easy way of enumerating an entire folder tree unless you dabble in recursion. This would of course mean some overhead in translation and procedure call setup.

 

Isn't it just much simpler to do something like

 FOR /R  %a in (.) do @echo  %a

 

Try doing the equivalent of the following but in VBS

 

FOR /F (tokens=1,2 delims=,) %%a IN (userlist.txt) DO @ECHO User name is %%a. Full name is %%b

 

Command subsitution is another area. You could shell out and pipe to a file but it's just so much easier to do

FOR /F %%a IN  ('dir /b') DO @ECHO %%a

 

These are really trivial examples but to do the same thing in VBS would take lots of lines, especially the file management (texts treams, arrays, read line, split, manip, join, write line, blah, blah, blah.... do me a favour!)

 

My challenge to VBS coders. Write a script to archive all the INI files on the C: drive using NT Backup which will be the only external program you are allowed to call.

 

Now I'm not saying there should be an exclusive choice between BAT/CMD and VBS( or JS for that matter). VBS offers more control but in some situations it can be qutie cumbersome.

Posted

I'd leave the logon BAT alone. I have nothing for logon, but looking at the stuff I've written recently for my toolkit:

 

Batch: For making a long series of CL calls, maybe with a few "if exists".. to save typing complex command lines I use a lot... or to remember rarely used and forgettable command lines. FOR is indeed an occasionally useful exception (my last use appended).

 

Script [JS]: Things that need a lot of string manipulation or serious functions. Things that need to talk to the registry or AD or WMI. None of mine launch other processes.

 

dotNet [JS, C#]: Things that are impossible or a zillion times easier than normal script courtesy of some everso handy dotNet Framework class or other.

 

Don't overlook dotNet. If you don't have it installed everywhere yet, you will and you can code-tweak anywhere because it installs compilers for JS, C# and (if you must) VB.

 

for /d %%I in ("*") do (call :fn01 "%%~I")
goto :eof

:fn01
rem point a few CL utils at sub-dir in %1
goto :eof

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...