ActiveXPoSH - quiet mode?

This forum can be browsed by the general public. Posting is no longer allowed as the product has been discontinued.
This topic is 12 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
hitec92407
Posts: 8
Last visit: Sun Oct 09, 2011 7:39 am

ActiveXPoSH - quiet mode?

Post by hitec92407 »

Hi

ActiveXPosh, Exhange 2007 EMS (32Bit), WinXP SP3

I'm using ActiveXPosh with vbscript.

When I execute a powershell command, the command executes as expected. However, each time a command is executed with the ActiveXPoSH.Execute statement, a window very quickly opens and closes on the desktop. I think the window is displaying "Completed" but it happens so fast I can't be sure.

I tried changing the output property to the three different modes to see if it made a difference, but it didn't help.

Is there a way to tell ActiveXPosh to execute quietly in the background?

thanks

User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

ActiveXPoSH - quiet mode?

Post by Alexander Riedel »

That sounds like a progress message. the host in the component does not display any messages by itself. What specific command are you using? Maybe I can replicate that.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
hitec92407
Posts: 8
Last visit: Sun Oct 09, 2011 7:39 am

ActiveXPoSH - quiet mode?

Post by hitec92407 »

Here is the complete test code. The sleep statements are for testing only.
I'm using this with Exchange management tools (2007) but the window momentarily displays an any powershell command.

And yes...it does appear to be a progress message of some sort.
Hope you can help...

'==============================================
Option Explicit
Dim ActiveXPosh, strUser, sDeviceIDList
Const OUTPUT_CONSOLE = 0Const OUTPUT_WINDOW = 1Const OUTPUT_BUFFER = 2
strUser= "user01"
createActiveXPosh
sDeviceIDList = runExPS("Get-ActiveSyncDeviceStatistics -Mailbox:" & strUser & "| Select-Object DeviceID,DeviceType")MsgBox sDeviceIDList
call sleep(2000)runExPS("Get-Help")call sleep(2000)runExPS("Get-Mailbox user01")call sleep(2000)runExPS("Get-Mailbox user01")call sleep(2000)
Wscript.Quit
Function createActiveXPosh() Dim iSuccess, sMsg ' Create the PowerShell connector object Set ActiveXPosh = CreateObject("SAPIEN.ActiveXPoSH") If IsObject(ActiveXPosh) Then ' load the Powershell engine, but dont load profiles iSuccess = ActiveXPosh.Init(vbFalse) If iSuccess <> 0 Then sMsg = "ActiveXPoSH Init failed" Else If ActiveXPosh.IsPowerShellInstalled Then sMsg = "Ready to run PowerShell commands" ' Add the Exchange snapin iSuccess = ActiveXPosh.Execute("Add-PSSnapIn Microsoft.Exchange.Management.PowerShell.Admin") If iSuccess <> 0 Then sMsg = "Unable to add Exchange Snapin" Else sMsg = "Exchange Powershell ready." End if Else sMsg = "PowerShell not installed" End If End If Else sMsg = "Sapien ActiveXPoSH is not Installed" End If If iSuccess <> 0 Then MsgBox sMsg WScript.quit Else MsgBox sMsg End IfEnd Function
Function runExPS(strCmd) Dim objShell, objFSO, objFile, strTmpFile, strContents Dim intReturn intReturn = 1 Set objShell = CreateObject("Wscript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") strTmpFile = objShell.ExpandEnvironmentStrings("%temp%") & "" & objFSO.GetTempName
On Error Resume Next ActiveXPosh.OutputMode = OUTPUT_CONSOLE intReturn = ActiveXPosh.Execute(strCmd & " | export-csv " & strTmpFile & " -notype") Err.Clear On Error Goto 0 If objFSO.FileExists(strTmpFile) Then Set objFile = objFSO.OpenTextFile(strTmpFile,1) If Not objFile.AtEndOfStream Then strContents = objFile.ReadAll strContents = Replace(strContents,Chr(34),"") Else strContents = "" End If objFile.Close runExPS = strContents objFSO.DeleteFile strTmpFile, True Else runExPS = intReturn End If strContents = "" Set objShell = Nothing Set objFSO = Nothing Set objFile = NothingEnd Function
Sub sleep(intmsecs) Dim objShell, objFSO, objOutputFile, strTmpFile Set objShell = CreateObject("Wscript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") strTmpFile = objShell.ExpandEnvironmentStrings("%temp%") & "" & objFSO.GetTempName strTmpFile = Replace(strTmpFile,".tmp",".vbs") Set objOutputFile = objFSO.CreateTextFile(strTmpFile, True) If objFSO.FileExists(strTmpFile) Then objOutputFile.Write "wscript.sleep WScript.Arguments(0)" objOutputFile.Close objShell.Run strTmpFile & " " & intmsecs, 1 , True objFSO.DeleteFile strTmpFile, True End If
Set objShell = nothing Set objFSO = nothing Set objOutputFile = nothing strTmpFile = "" End Sub
User avatar
hitec92407
Posts: 8
Last visit: Sun Oct 09, 2011 7:39 am

ActiveXPoSH - quiet mode?

Post by hitec92407 »

Also...the script works.
It just that I get that momentary flash of a window when I run Exchange powershell commands.hitec924072011-10-09 14:40:34
This topic is 12 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.