Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Can't get vbs to run from Job

Author  Topic 

MaritimeMadness
Starting Member

10 Posts

Posted - 2009-06-18 : 11:11:50
I have a job and I've selected ActiveX and vbscript.

Here's my code:

Dim WshShell, objFSO, strFolder, objFolder, objFiles, objFile
Dim objEmail, strBody ,strFrm, strTo, strSubject, iNumErr, errorOccurred

set WshShell = CreateObject("wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
errorOccurred = False

strFolder = "C:\IWebPages\BMO\Encrypted" 'folder where files we want are stored


iNumErr = 0


WshShell.CurrentDirectory = strFolder

Set objFolder = objFSO.GetFolder(strFolder)
Set objFiles = objFolder.Files

'On Error Resume Next
For Each objFile In objFiles
If Right(objFile.Name,3) = "gpg" Then
Dim NewFileName
NewFileName = Replace(objFile.Name, ".gpg", "")

if objFile.DateCreated > now-7 then
'-e = encrypt
'-d = decrypt
'-r name = the name of the Key used to encrypt aka the recipient
'--yes = overwite files If they exist
WshShell.Exec("gpg.exe -d --output " + NewFileName + " --passphrase #$9sd898h2n97s76029sa8m -r MaritimeTravel --yes " + strFolder + "\" + objFile.Name)
objfso.CopyFile("C:\IWebPages\BMO\Encrypted\" + NewFileName, "C:\IWebPages\BMO\Decrypted" + NewFileName)

End If
'catch errors
If Err.Number <> 0 Then
errorOccurred = True
iNumErr = iNumErr + 1
strBody= strBody + _
"Error occured encrypting file: " + objFile.Name + " Error number " + Err.Number + _
" Error Discription: " + Err.Description + vbCr

End If
End if
Next

msgbox "Done"


When I run the job I keep getting an error that says:

"Cannot use parentheses when calling a Sub. Error on line 30"

Can't figure out what's wrong?

Any thoughts?
   

- Advertisement -