Jump to content

Need help converting vbs to au3


Flak
 Share

Recommended Posts

What I'm trying to accomplish is to automate the process of reattaching pst files in Outlook.  In a perfect world this script would check for currently attached pst files, unload them then search the user's network drive and pc for PST files and then move them all to a central location.  Then reattach them from that location.  But since all of this is new to me, and I apparently took the extremely long route the first time.  I found this and instantly felt ashamed at the way I was taking, lol....  So how would this be converted to au3 and hopefully I can use this as an example going forward.

So what we do is manually detach pst files, run a search for the user pst(s) then move everything to a central location.  We then run this script, tell it where the pst files are located and it re-attaches all of them.

const ForAppending = 8

start_folder = inputBox ("Enter Full Path to PST Files")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutlook = CreateObject("Outlook.Application") 
Set objFolder = objFSO.GetFolder(start_folder)
set objTextFile = objFSO.OpenTextFile ("C:\Temp\PST_ADD_Log.txt", ForAppending, True)

For Each objFile In objFolder.Files
    If LCase(objFSO.GetExtensionName(objFile.Name)) = "pst" Then
        WScript.Echo "Found PST:" & objFile.Name
            On Error Resume Next
        objOutlook.Session.AddStore objFile.Path
            If Err.Number <> 0 Then
                objTextFile.WriteLine(objFile.Name & vbTab & "PST is corrupt or in use")
            else
                objTextFile.WriteLine(objFile.Name & vbTab & "PST opened successfully")
            End If
    End If
Next
Link to comment
Share on other sites

Please have a look at my OutlookEX UDF. It has some functions to work with PST stores.

If you have questions I'm happy to help.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

this should get you started

$obj = ObjCreate("Scripting.FileSystemObject")

I would agree, but there are also built-in functions in AutoIt worth learning as far as File System accesses. 

Perhaps ObjCreate is useful enough to get started as something that could be used with the "Outlook.Application" COM object.

After some prolonged expose to AutoIt you'll discover the value of using UDFs too as water recommended (and developed.)

I endorse both.

Link to comment
Share on other sites

To work with files in AutoIt as shown in the example VBS code you don't need to use a FileSystemObject.

AutoIt has functions to directly work with files.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

To work with files in AutoIt as shown in the example VBS code you don't need to use a FileSystemObject.

AutoIt has functions to directly work with files.

ahem :whistle:

that's what I was eluding too.

...there are also built-in functions in AutoIt worth learning as far as File System accesses.

Link to comment
Share on other sites

Sorry for my "double" post - just noticed that is was already mentioned by you.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...