Login | |
|
 |
RE: looking for help in CreateObject("Wscript.Shel... - 7/6/2006 4:34:45 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
Change this line: shellobj.Run("%COMSPEC% /C blat " & backupLog & " -t " & email_recipients & " -f " & email_from & " -server " & smtp_server & " -s " & email_subject0) to be this: strCMD = "%COMSPEC% /C blat " & backupLog & " -t " & email_recipients & " -f " & email_from & " -server " & smtp_server & " -s " & email_subject0 WScript.Echo strCMD shellobj.Run strCMD Then type whatever it displays exactly as is at the command line a see if it works. I suspect that you need some "s somewhere in there.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: looking for help in CreateObject("Wscript.Shel... - 7/6/2006 6:04:12 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
Look at the documentation for the .Run method. Especially the second and third parameters. Setting the third parameter to True will make script execution wait until the process that .Run starts completes it's operation.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: looking for help in CreateObject("Wscript.Shel... - 7/6/2006 10:32:08 PM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
VBScript does not enforce variable typing so it does not complain about something that other languages would complain about. You declare your variable as a stirng but you compare it as a decimal. Try doing it one way or the other. Actually to make thing a little more clear I would use True/False instead of 1/0.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: looking for help in CreateObject("Wscript.Shel... - 7/6/2006 10:43:17 PM
|
|
 |
|
| |
ehvbs
Posts: 2114
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
|
Hi desert_storm28, plan before code: ================= Conditions: (1) Alerts : (c) You want emails (d) You don't want emails (2) The could be 0, 1, 2, ... Error, let's reduce this to Errors : (a) There is at least one Error (b) There are no Errors att all Actions: (1) Send email (a) SUCCESS (b) FAIL (2) Don't send email (c) ./. What to do When (check all possible combinations of conditions ============================================================== Errors Yes \___ Send FAIL Alerts Yes / Errors Yes \___ Send FAIL (I think, you may decide otherwise) Alerts No / Errors No \___ Send SUCCESS Alerts Yes / Errors No \___ Don't Send Alerts No / Variables (initialized at start to reasonable values): ====================================================== Dim nErrors : nErrors = 0 ' Integer to count Errors; initially 0 Dim bErrors : bErrors = (0 < nErrors) ' Bool to reduce 0,1,2,..Errors to No Or Some Dim bDoAlert : bDoAlert = True ' or False, as you like it Dim sDecision : sDecision = "" ' what to do in clear text (don't know yet) ' but possible values are ' "Send FAIL" ' "Send SUCCESS" ' "Don't Send" Determine conditions: ===================== If <CommandLineArgSilent> Then bDoAlert = False ... If <SomethingIsWrong> Then nErrors = nErrors + 1 ... bErrors = (0 < nErrors) Implement Condition => Decision mapping systematically (may be inefficient): ============================================================================ ' Errors Alerts If bErrors Then If bDoAlert Then sDecision = "Send FAIL" ' True True Else sDecision = "Send FAIL" ' True False End If Else If bDoAlert Then sDecision = "Send SUCCESS" ' False True Else sDecision = "Don't Send" ' False False End If End If Implement Action (again, not short or fast but easy to see/check): ================================================================== Select Case sDecision Case "Send FAIL" WScript.Echo bErrors, bDoAlert, sDecision, "Failure" Case "Send SUCCESS" WScript.Echo bErrors, bDoAlert, sDecision, "Success" Case "Don't Send" WScript.Echo bErrors, bDoAlert, sDecision, "you can't see this, because I didn't send!" Case Else WScript.Echo "***** Fatal Programmer's Error *******" End Select Implement test code to gain confidence: ====================================== Dim nErrors, bErrors, bDoAlert, sDecision For Each nErrors In Array( 0, 5 ) For Each bDoAlert in Array( True, False ) bErrors = (0 < nErrors) WScript.Echo "-------- " & nErrors & " " & bDoAlert & " --------" If bErrors Then If bDoAlert Then sDecision = "Send FAIL" ' True True Else sDecision = "Send FAIL" ' True False End If Else If bDoAlert Then sDecision = "Send SUCCESS" ' False True Else sDecision = "Don't Send" ' False False End If End If Select Case sDecision Case "Send FAIL" WScript.Echo bErrors & " " & bDoAlert & " " & sDecision & " Failure" Case "Send SUCCESS" WScript.Echo bErrors & " " & bDoAlert & " " & sDecision & " Success" Case "Don't Send" WScript.Echo bErrors & " " & bDoAlert & " " & sDecision & " you can't see this, because I didn't send!" Case Else WScript.Echo "***** Fatal Programmer's Error *******" End Select Next Next It looks kind of ugly even when viewed using a monospaced font, but I think you'll get the drift and I hope you'll find that this method will get you thru more complicated cases painlessly. Good luck! P.S. As ebgreen suggested: use numbers to count, but booleans to store binary decisions.
|
|
| |
|
|
|
 |
RE: looking for help in CreateObject("Wscript.Shel... - 7/11/2006 1:13:56 AM
|
|
 |
|
| |
desert_storm28
Posts: 13
Score: 0
Joined: 7/6/2006
Status: offline
|
Sir, actually, am not a programmer, but I respect your coding standards, i am currently an OJT in a small firm as systems administrator, and I am only learning VBS in the past few days, and they assigned me a task to put together all their backup script into one VBS script, because some of their backup script was written in batch file. Right now, they had separate VBS scripts and batch file to backup the System State, Exchange Information Store, SQL Servers databases, and all important files in the server. And they'll be using the script I'm currently doing in all their servers as standard backup script in the future. They are using the built-in ntbackup in Windows, the 7-zip compression utility to compress the ".bkf" file, the blat utility to send an email alert, and their paging terminal to send a pager alert. So, my task is to put all together these scripts into one, because of pressure, i made a hurry to finish off the script without any programming standards, and the other code of this script was taken off from other websites, and my task is to complete the following in one script only: 1) an option to backup the System State or not. 2) an option to backup only the System State. 3) an option to backup the System State together with the ".bks" selection file. 4) an option to send email and pager success/fail alert to administrator after the backup process, and they told me to put an option also to turn off/on these feature, because they do not want to un-comment the code if they do not want an alert. 5) an option for local and remote house keeping. 6) an option to copy the backup to remote media1 if current day is even, and to remote media2 if the current day is odd. Actually, the script is almost done, and what i will do now is to improve the coding standards. Please find below the entire script: | | |