Options

batch vs vbs question

ranjitcoolranjitcool Member Posts: 80 ■■□□□□□□□□
Hey Guys,

I was trying to get the batch script to work, while my manager told me that vbs does the same and is more easier.

But how on earth do i execute a vb script ? Can i type it in a notepad and save it as a .vbs ?

I know a little vb but never used it in this manner.

The following is the batch script of what i am trying to acheive.

Output shud be filename_date.sql
@echo off
:Main
for /F "tokens=2,3,4 delims=/ " %%i in ("%date%") do set d=%%k%%i%%j
echo %d%
mysqldump gradschool > gradschool_%d%.sql
pause

:EndProg
echo *End of file*

please advice me i am very new to windows scripting.

thanks
rj
Cleared Network+, MCTS.
Want to clear - CCSA, CCNA, VCP for now.

Spending time @ www.itgrunts.com - Tech Juice, Not from Concentrate!

Comments

  • Options
    rbutturinirbutturini Member Posts: 123
    You can type it in notepad (although it works better in something like notepad++ which is freely downloadable).

    to execute the script from the command line type cscript and the file name of the .vbs file you want to run.
  • Options
    ranjitcoolranjitcool Member Posts: 80 ■■□□□□□□□□
    thanks for the reply,

    and can u direct me to a good tutorial that projects at teaching me vscript for system management rather than application programming..

    i had googled it but it leads me to app programming, or are they same.

    thanks
    rj
    Cleared Network+, MCTS.
    Want to clear - CCSA, CCNA, VCP for now.

    Spending time @ www.itgrunts.com - Tech Juice, Not from Concentrate!
  • Options
    dvalenzueladvalenzuela Member Posts: 123
    ranjitcool wrote:
    thanks for the reply,

    and can u direct me to a good tutorial that projects at teaching me vscript for system management rather than application programming..

    i had googled it but it leads me to app programming, or are they same.

    thanks
    rj

    http://www.w3schools.com/Vbscript/default.asp

    http://www.devguru.com/Technologies/vbscript/quickref/vbscript_list.html

    Check those links you will be ok for a starting.
    close to MCSA!!
  • Options
    ranjitcoolranjitcool Member Posts: 80 ■■□□□□□□□□
    Thanks guys!
    Cleared Network+, MCTS.
    Want to clear - CCSA, CCNA, VCP for now.

    Spending time @ www.itgrunts.com - Tech Juice, Not from Concentrate!
  • Options
    ranjitcoolranjitcool Member Posts: 80 ■■□□□□□□□□
    None of the tutorials show me how to type the program in a notepad and execute it in command prompt !!!

    the tutorials are all focused on web based programming

    can you help please
    Cleared Network+, MCTS.
    Want to clear - CCSA, CCNA, VCP for now.

    Spending time @ www.itgrunts.com - Tech Juice, Not from Concentrate!
  • Options
    sprkymrksprkymrk Member Posts: 4,884 ■■■□□□□□□□
    ranjitcool wrote:
    None of the tutorials show me how to type the program in a notepad and execute it in command prompt !!!

    the tutorials are all focused on web based programming

    can you help please

    Well, you just do it like you would a batch file, but rather than save it as a .bat, you save it as a .vbs. Then to execute it, you would either double click the .vbs file, or launch it from the cmd line by typing:
    cscript filename.vbs
    


    Looks like most of the focus nowadays is moving away from vbscript and onto powershell. If you're starting from scratch, I would definately go with powershell over vbscripting. However, here are some vbscript templates that can be useful in making your own quick solutions:

    http://www.microsoft.com/technet/scriptcenter/findit.mspx

    Don Jones used to have some nice tutorials on vbscripting, but it looks like even he has moved on to powershell. Your best bet might be to pick up a book on amazon.
    All things are possible, only believe.
  • Options
    ranjitcoolranjitcool Member Posts: 80 ■■□□□□□□□□
    Hey Sprkymrk,

    Thanks for the reply, wow and thanks for telling me to have a look at powershell.

    I will look into it right away and yeah i am starting from scratch w.r.t windows

    do u know any good powershell stuff ?

    please let me know

    thanks
    rj
    Cleared Network+, MCTS.
    Want to clear - CCSA, CCNA, VCP for now.

    Spending time @ www.itgrunts.com - Tech Juice, Not from Concentrate!
Sign In or Register to comment.