Can I use Powershell to copy text from another window? - powershell

I have OneDrive files which I can access through Microsoft Word or the browser, but not via a script. I need to pass the contents of one of these files as a variable for something later down the line in my script.
Googling this gives me lots of links explaining how to copy something from the Powershell window and paste it, which isn't what I want to do.
I need Powershell to open a Microsoft Word file, copy the text inside the file, and save the result as a text file. Is there any way to do that in Windows 10 with Powershell 5? I can't install any software.

Related

PowerShell - actions over files in folders and subfolders

So basically, there is a tab in a website containing thousands of .pdf files. It's a list with folders of which some of them have subfolders. Obviously, these folders/subfolders contain the files. In order to download the files, I need to open each and every folder, right click on every single file and click download. Is there a way to automate this recursively with PowerShell for all the files? Or maybe UiPath?
If you are unable to access the server files directly, so not through the website but through Windows Explorer then that would probably rule out, or at least make it quite trick to use power shell.
However this is something that UiPath should be able to cope with quite easily. Several automation's I have worked on do a similar thing.
Essentially the automation would need to do the following
login
enter search terms
for each returned folder
for each file in folder
Download file
for each folder in folder
repeat above
Essentially you need to build a recursive loop to loop through all of the folders and files, downloading a file when you encounter one

after converting powershell script to .exe listbox index is not working

I have created a script for list the names in the listbox which is given as input in the textbox. It works fine while am running in the Powershell ISE. But after i did converting to .exe files now if add any input via textbox the same which is supposed to be displayed in the listbox is not happenning.
Anyone could help on this?
I did converting process by using PS2EXE application and its method.
A a sample code snippet is required for better solutions.
The PS2EXE does not provide a standalone-independent file that can be run without Powershell, because the tool in itself is a PowerShell script which does the in-memory compilation and generates the EXE file.
P.S: There is also a chance that the functionality of such EXE files may be impacted as well.
You can look up this link for more information :
Microsoft-Technet- PS2EXE

how to check if a .html file is open, if yes, close it using windows PowerShell script

I am new to PowerShell scripting. I would like to know if i can check whether a html file is open. If it is opened, then i would like to re-open it after running the same script.
My script creates a html file and using Invoke-Item, i am opening it. The next time i run the same script, the updated html file gets opened in the new tab. I want my script to close the previously opened file right before opening the new one or some similar logic.
By using Invoke-Item you actually are asking Windows' Explorer to open the file with the default application that's registered for .html files. In out of the box configuration, that's Internet Explorer or Edge. This, of course, can be customized.
Depending on the browser used, there might be a COM interface for querying browser status. As how to do that is subject to another a question, as it really depends on the browser. Looking for, say, file handles might or might not work, as browsers tend to open files in read only mode - they are not supposed to modify it anyway.
Anyway, this sounds like another a XY problem. Please edit the question and describe what problem are you really trying to solve; maybe there's better a way.

Possible to save a file in AutoHotKey script?

i want to save a .png file in to a AutoHotKey script, so that when i run the script it make the .png file.
i tryed to open the .png with notepad++ and copy the text in to a FileAppend command but there are just to many """ and "%" characters
I havent tested (1) and (2), but here are three different approaches:
modifying AutoHotkeySC.bin with a third-party tool like ressource hacker
building a .dll which you then might access via ahk
pack the complete file into your script and start its creation upon function calling. I saved this guy's V2.3 script up to pastebin. Works perfectly fine for me.
regards

Windows: Execute Batch File for a Custom Context Menu Item

I am looking to add a new item in a right click context menu for a certain file type. I suppose it would be easiest to run a batch file with the full path of the file as an argument. I need to rename the file, unzip it, then rezip it, then rename it. I suppose winzip command line would be appropriate tool to help with that, unless someone else has a suggestion.
My questions are:
- How can I add a custom context menu item based on file type
- How can I pass the file name as an argument to the batch file from the context menu
- Finally this may go out to 2-3 people, and it might be easier to simply have an installer that sets this up for them. Anyone know of any free installers that could do this?
Some details about why I am trying to do this:
I have a tool that is zipping things correctly, the program that is reading the zip files is not unzipping to standards it seems. It unzips in winzip legacy mode or something. Rather than fix a working program/investing time or attempt to do some ultra-fancy, crazy fix on a linux server for zipping into winzip legacy format a workaround seemed appropriate for now. These processes only really occur internally, but they are still painful/annoying to do.
7zip is free, you might want to use that if you need to bundle the zip utility
Customizing a Shortcut Menu Using Static Verbs
%1 in the command string in the registry is replaced with the filename
Inno Setup, NSIS or WiX