I needed to find the GroupWise Archive Location, for my company, in the end we want to migration anyone that still has their archive on a local drive to a network drive. So the first step is identifying where their archive currently is. This setting isn't to be found anywhere on on the local PC, But you can see the setting in the GroupWise Client Settings. So I came up with this VB script that can locate it and copies it to the Windows Clipboard, and then display's it back to you. For this example it simply "echo"'s the results back, but you can use it for whatever action you want to take from there.
I Tested this on Groupwise 8 client we have here. You may have to adjust some sendkey actions depending on your version if it isn't found in the identical location under client properties. If you know of a better way to evaluate this, on a per client basis, leave a reply!
'-----------------------------------------------------------------
'Written by Corey Sines
'Version 1.0
'Purpose: Open's the GroupWise Client settings and reads the contents of the
' Archive Location into the Windows Clipboard.
' This setting is stored in the user.db file / GroupWise Sytem and I found
' no other way to retrieve this setting, on a per client basis, other
' than through the GroupWise Client options GUI.
'-----------------------------------------------------------------
'On Error Resume Next
Dim objShell, objHTML, ClipboardText
Set objShell = WScript.CreateObject("WScript.Shell")
' Terminates the process gwsync.exe if active, causes issues running groupwise client repeatedly
Const strComputer = "."
Dim objWMIService, colProcessList
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'gwsync.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
' Launches the groupwise client, does nothing if already launched.
objShell.Run "C:\Novell\GroupWise\grpwise.exe", 3, false
If Err.Number Then
Wscript.Echo "Unable Lauch GroupWise! Script Aborting!"
Wscript.Quit(1)
End If
Call RunAppLoop("Novell GroupWise - Mailbox") 'calls loop to bring the Groupwise client to Forground to sendkeys
' Sendkeys with sleep commands to allow for system delays
Wscript.Sleep 100
objShell.SendKeys "%T"
Wscript.Sleep 100
objShell.SendKeys "O"
Wscript.Sleep 100
objShell.SendKeys "{ENTER}"
Wscript.Sleep 100
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
Wscript.Sleep 100
objShell.SendKeys "{RIGHT}"
objShell.SendKeys "{RIGHT}"
Wscript.Sleep 100
objShell.SendKeys "{TAB}"
objShell.SendKeys "^C"
Wscript.Sleep 100
objShell.SendKeys "{ENTER}"
objShell.SendKeys "%C"
'Accessing data copied to the clipboard in the above action
Set objHTML = CreateObject("htmlfile")
ClipboardText = objHTML.ParentWindow.ClipboardData.GetData("text")
wscript.echo "GW Archive Location is set to: " & ClipboardText 'should display Archive location information
Set objShell = nothing
Set objHTML = nothing
wscript.quit(0)
'--------------------------------------------------------------------
Sub RunAppLoop(APPNAME) ' brings the desired application to the Forfront, loops till successful or timesout after 30 sec
Dim Success
Set objShell = WScript.CreateObject("WScript.Shell")
x = 1
Do Until Success = True or x = 300
objShell.AppActivate(APPNAME)
Success = objShell.AppActivate(APPNAME)
'Wscript.echo Success
'Wscript.echo "x = " & x
Wscript.Sleep 100
x = x + 1
Loop
if x = 300 then ' Sleep 100ms x 300 tries in the loop = 30 seconds
Wscript.echo "The Operation Timed out, unable to locate a running application named: " & APPNAME
Wscript.quit(1)
End if
End Sub
I found a better way using GW Object API
ReplyDelete'------------- Begin Section to Check Arguments and set Variables, or Return Proper Usage------------------
dim Args, sGWArchivePath, sGWUserName, sGWPassword
If wscript.arguments.count = 3 then ' needs all 3 arguments
Set Args = Wscript.Arguments
Else
Wscript.echo "Usage: GWMailArchive.vbs PathtoArchive GWUsername GWPassword"
wscript.quit(1)
End If
' Setting variables to Arguments supplied
sGWArchivePath = Args(0)
sGWUserName = Args(1)
sGWPassword = Args(2)
' ------------------------------------------------End Section----------------------------------------------
'Script starts here...
On Error resume next
dim GWApp, GWAccount
Set GWApp = CreateObject("NovellGroupWareSession") ' instantiating the COM Object for "GW Object API"
Set GWAccount = GWApp.Login(sGWUserName,SGWPassword) ' Creating and logging into a GroupWise Session
wscript.echo "GroupWise Archive Path: " & GWAccount.PathToArchive & " : GroupWise FID for User: " & GWAccount.AccountProperty(9) & vbCrLf
set GWApp = nothing
set GWAccount = nothing
great content! cpap masks for side sleepers I found your blog on google and loved reading it greatly. It is a great post indeed. Much obliged to you and good. keep it up..
ReplyDelete