PDA

View Full Version : X Basic convert to VbScript


ABC123

gabelgee
06-16-2011, 10:46 AM
set DateString=%Date:~6,4%.%Date:~3,2%.%Date:~0,2%

%WinDir%\syetem32\ntbackup.exe backup "@C:\BackupTasks\Daily.bks" /n
"Backup_%DateString%" /d "Backup_%DateString%" /v:no /r:yes /rs:no /hc:off /m normal
/j "Backup_%DateString%" /l:s /f "C:\Bckups\Backup-%DateString%.bkf"

I know how to code in Vb but am fuzzt with Vbscript especially the conversion of x basic to VbScript. If you could push me in the right direction, I would appriciate it. Thank you

MikeC
06-16-2011, 12:03 PM
Hi ???,
Welcome to the messageboard! We use this almost exclusively as a knowledgebase and once the nuances of how to search it are figured out, you will find most desktop answers here.

You are really limiting yourself to answers only from anyone not only that is familiar with vbscript, but also to those who understand what it is you are trying to achieve.

If you tell us what exactly it is you are in need of (what is the script supposed to do) and preferably show us also what you have tried that we can modify to help you, more people here will be able (and willing!) to provide a solution.

aschone
06-16-2011, 01:34 PM
set DateString=%Date:~6,4%.%Date:~3,2%.%Date:~0,2%

%WinDir%\system32\ntbackup.exe backup "@C:\BackupTasks\Daily.bks" /n
"Backup_%DateString%" /d "Backup_%DateString%" /v:no /r:yes /rs:no /hc:off /m normal
/j "Backup_%DateString%" /l:s /f "C:\Bckups\Backup-%DateString%.bkf"


This isn't xbasic code. This appears to have come from a DOS batch file that runs a NTbackup job.
Also there is a typo, I have corrected it and highlighted in red.

This will get you started.
http://www.geekinterview.com/talk/15963-how-to-execute-command-line-vbscript.html

Btw; I too have toyed around with running my backup jobs via VBScript, I eventually gave up and wrote a batch file which I schedule to run via task scheduler. The batch file approach was much simpler than the VBScript. I have attached a copy of my backup batch file, change the extension from .txt to .bat (forums didn't like the .bat extension).

gabelgee
06-17-2011, 07:41 PM
I'm trying to attach a screen shot of the batch file and all i get is an error could someone help direct this back up file code.

Al Buchholz
06-17-2011, 08:58 PM
what is the error?

You may need to save the image as a smaller jpg or png

What file type are you using and what is the file size?

Stan Mathews
06-17-2011, 11:03 PM
Why would you attach a screenshot of what is basically a text file? Why not just attach the file itself?

gabelgee
06-27-2011, 04:54 PM
Hey Mike i just moved to S.Texas from Appleton, it would be great if i could throw some x-basic questions at you if thats oK ...

MikeC
06-27-2011, 07:31 PM
Well, most times it is most beneficial to keep questions (and answers) on the message board. I and others have taken some questions off-board when they are just too hard to fathom the problem and there is a need to do so to eliminate guesswork and such. The issue you are having difficulty with has not gotten to that point yet as you have not given enough information (attach the actual text file as Stan suggested).

Also, I cannot imagine meeting off-board with someone when I do not even know their first name!! :grin:

(must have been quite a change moving from Appleton to south Texas btw!)

gabelgee
07-05-2011, 10:35 AM
Hey thanks thats cool, and yes it is very different down here. Anyhow I wanted to create this back up script and wanna test it. Any suggestions? And would you walk me through the code you sent, I'm looking for the last line of code.
Abel :)

aschone
07-05-2011, 12:04 PM
I would like to help you; really I would. However I am not understanding what it is you are wanting or needing.

gabelgee
07-05-2011, 12:35 PM
In my orginal message I' looking to pass the last string as a batch file so I can get my back up going. Thanks

aschone
07-05-2011, 01:25 PM
In my orginal message I' looking to pass the last string as a batch file

Your question is confusing.
You want to pass the string as an argument to a batch file or do you want to save the string to a batch file?

Stan Mathews
07-05-2011, 01:37 PM
In xbasic you perform variable substitution like this.


DateString= "Date:~6,4%.%Date:~3,2%.%Date:~0,2"


cmd = "%WinDir%\syetem32\ntbackup.exe backup \"@C:\BackupTasks\Daily.bks\" /n \"Backup_%"+DateString+"%\" /d \"Backup_%"+DateString+"%\" /v:no /r:yes /rs:no /hc:off /m normal /j \"Backup_%"+DateString+"%\" /l:s /f \"C:\Bckups\Backup-%"+DateString+"%.bkf\""

? cmd
= %WinDir%\syetem32\ntbackup.exe backup "@C:\BackupTasks\Daily.bks" /n "Backup_%Date:~6,4%.%Date:~3,2%.%Date:~0,2%" /d "Backup_%Date:~6,4%.%Date:~3,2%.%Date:~0,2%" /v:no /r:yes /rs:no /hc:off /m normal /j "Backup_%Date:~6,4%.%Date:~3,2%.%Date:~0,2%" /l:s /f "C:\Bckups\Backup-%Date:~6,4%.%Date:~3,2%.%Date:~0,2%.bkf"

gabelgee
07-05-2011, 02:07 PM
Sorry for the confusion, I want to pass the string as an argument to a batch file. Thank you

aschone
07-05-2011, 03:06 PM
Sys_Shell (http://support.alphasoftware.com/alphafivehelpv10/Functions/SYS_SHELL%28%29.htm)

I think sys_shell can do what you want.

gabelgee
07-07-2011, 11:25 AM
Sorry for all the confusion I think it's because I have been confused. I'm looking for either a batch file or a VB Script that will do a schduled back up from aserver to a group of CPU's using agents. Thank everyone for the help sorry i was not clear at first and still am a little unsure in what direction I should be going in.

aschone
07-07-2011, 06:54 PM
Sorry for all the confusion I think it's because I have been confused. I'm looking for either a batch file or a VB Script that will do a schduled back up from aserver to a group of CPU's using agents. Thank everyone for the help sorry i was not clear at first and still am a little unsure in what direction I should be going in.

First off this forum is for Alpha5 database users to ask for support regarding Alpha5 products. You are asking for help regarding VBScript or Batch Scripting of a NTBackup job. Neither of which are supported here and as such you will find limited help here. However I have uploaded a batch file that will do what you are asking for. It is in post #3. Have you gotten a chance to look at it? If you still need help I will try to help as best as I can.

gabelgee
07-11-2011, 10:16 AM
Thank you for your assistance.