comobject

How to extract metadata using a specific filename (get-childitem) rather than looping through ComObject namespace items

血红的双手。 提交于 2019-12-12 03:59:24
问题 I have found multiple code snippets to scroll through a folder and display the metadata of each item in the folder, like this: function funLine($strIN) { $strLine = "=" * $strIn.length Write-Host -ForegroundColor Yellow "`n$strIN" Write-Host -ForegroundColor Cyan $strLine } $sfolder = "S:\Temp" $objShell = New-Object -ComObject Shell.Application $objFolder = $objShell.namespace($sFolder) foreach ($strFileName in $objFolder.items()) {funline "$($strFileName.name)" for ($a ; $a -le 266; $a++) {

Powershell writing data into excel file

末鹿安然 提交于 2019-12-11 19:43:13
问题 hoping to get some help with what i'am trying to achieve here. i have two arrays $ActiveUsers and $InactiveUsers with 4 fields and following data in each $ActiveUsers = fahe532|Allyson Sullivan|34563|Cain,Ashley J pers274|Martha Walsh|53732|Mckenny,Josh fgh8458|Kayla Benson|95463|Trot,Cook K ndcf846|Sam Huff|56737|Mcghee,John vdfg456|Mark Jones |67843|Hart,Josh W fasf345|Amber Sean|24678|John,Kneel G $InavtiveUsers = fasd034|Colin Hart|35473|David, Casper aertp56|Andy Matthews|56849|Debby,

Startup Code for Loading COM Object for WCF Service

隐身守侯 提交于 2019-12-11 17:01:48
问题 I am currently have a WCF service that uses a COM DLL for its service. The COM object is only loaded once and saved via a singleton. The problem is the first run takes about 1 minute to load the COM Object. The WCF service is hosted via a Windows Service. I am wondering how can I load the COM Object singleton via the startup of the Windows Service. protected override void OnStart(string[] args) { if (host != null) { host.Close(); } Type serviceType = typeof(MyService); host = new ServiceHost

Start-job wait-job doesn't work with copy.here

丶灬走出姿态 提交于 2019-12-11 12:25:10
问题 I'm trying to copy files into a zip file. I used start-job and wait-job to wait for the copy process finish but it didnt work at all. This is the error when I call receive-job: Method invocation failed because [Deserialized.System.__ComObject#{a7ae5f64-c4d7-4d7f-9307-4d24ee54b841}] does not contain a method named 'copyhere'. + CategoryInfo : InvalidOperation: (copyhere:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound + PSComputerName : local This is my code $Shell = New

C# System.__ComObject returned when accessing Excel file

元气小坏坏 提交于 2019-12-10 17:57:26
问题 I am trying to access Excel file by code below: Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook book; Microsoft.Office.Interop.Excel.Worksheet sheet; Excel.Range range1 = null, range2 = null; CultureInfo ci = new CultureInfo("en-US"); Thread thisThread = Thread.CurrentThread; thisThread.CurrentCulture = new CultureInfo("en-US"); book = ObjExcel.Workbooks.Open(LinguisticInstructionsFileName); At

PowerShell Windows Installer Com Object

南笙酒味 提交于 2019-12-10 17:28:05
问题 I'm trying to modify the contents of an MSI file using Powershell. To do so I create an instance of a WindowsInstaller.Installer then use $installer.OpenDatabase and $database.OpenView. Similar functionality works in VBScript and I've seen samples on-line that appear to work. $installer = new-object -comobject "WindowsInstaller.Installer" $database = $installer.OpenDatabase("C:\Temp\Setup.msi", 1) For the above code, I get an error "Method invocation failed because [System.__ComObject] doesn

VS2010 will not display project properties (“underlying RCW”)?

烈酒焚心 提交于 2019-12-10 14:58:31
问题 Only sometimes (I haven't yet noticed a pattern), VS2010 shows the following error (where I'd expect the body of the property page to be) when I right-click on a project (various types of projects) and select "Properties": I can typically view the project pages after restarting VS2010. I'm using the RTM version. What can cause this error? 回答1: LepardUK. I had the same issue and finally found out what had gone wrong. It's misbehaving addin - TestDriven.NET. But things could be different for

Word.Application ComObject errors in PowerShell

假如想象 提交于 2019-12-10 09:32:38
问题 I'm unable to get a Word 2010 (14.0.x) document to SaveAs or Close using Powershell. From all the tuts online it seems like it should be working with 2.0, but I don't have that anymore. Simple case: $Path = "C:\MyDoc.docx" $Word = New-Object -comobject Word.Application $Word.Visible = $True #Do this to close it out without task manager $Doc = $Word.Documents.Open($Path) $Doc.SaveAs($Path) $Doc.Close() At this point everything works up until the saving and closing: Argument: '1' should be a

MSHTML HTMLHeadElementClass COM Error

≯℡__Kan透↙ 提交于 2019-12-09 02:04:38
问题 I'm currently working with MS HTML to insert a JavaScript code into websites. I made a reference to Microsoft HTML Object Library and types this code. IHTMLDocument2 doc = BrowserHost.Document as HTMLDocumentClass; IHTMLElement head = (IHTMLElement) ((IHTMLElementCollection)doc.all.tags("head")).item(null, 0); IHTMLScriptElement scriptObject = (IHTMLScriptElement)doc.createElement("script"); scriptObject.type = @"text/javascript"; scriptObject.text = TTS.TTSWebFactory.GetJavascript(); (

Windows10 script pin app to start menu

怎甘沉沦 提交于 2019-12-07 23:13:59
问题 I have a Universal App that I'm sideloading in Windows10. I would like to create a script (Powershell, VBS, batch, etc) to pin it to the Start Menu. I have found many examples of how to write a script that pins a desktop application (like this one: https://gallery.technet.microsoft.com/scriptcenter/Script-to-pin-items-to-51be533c ). I've tried using the script to pin the actual App .exe file located in C:\Program Files\WindowsApps... but that doesn't work. When I try and pin that way, I run