Automation using Loop command - automationanywhere

I am using a loop in a folder to check for acrobat reader if the folder contains pdf files but the loop is not running yet.
I am able to open the pdf file manually.
Can anyone suggest why I am not able to run the loop?
Loop While Window Exist ("Adobe Acrobat Reader") Then
Delay: (5 sec)
End Loop

You'll need to start the loop for "Each File in Folder" and specify the directory location to look in. Then You'll need to use the system variables $FileName$ and $Extension$ to look for each .pdf and open them. Please see my example code below.
AA's documentation on this process is here
If you're just checking to see if the file in a folder exists, then you would use the If/Else command for "File Exists" in place of the "Open File" command I provided as an example. AA also has documentation on that here.

Related

How can I automatically name the file after using Microsoft Print to PDF function in Power Automate?

I am trying to automate printing a list of PDF files in a folder and renaming the newly printed copies with a different name.
Workflow.
Drop all pdf files into folder
Loop through all files doing the following:
A "Print to PDF"
B Name new file when "Save Print Output As" window opens
I have created the following steps (see image below). The issue is that I cannot find a way to call the current item's name and input it into the file name and save it. What ends up happening is at the end of the execution of the flow, I get all the Save Output windows at once and I am not sure which one is what.
enter image description here

I need to open some files in a folder that contains "RPA" in their name. so how can I do that in automation anywhere?

I am creating a program that opens files in a folder that contains "RPA" in their name. so, how can I do that?
You will use Loop on File in Folder command, and if condition inside the loop to check if the file name includes RPA.
Loop on Files on Folder
If condition $Filename$ includes RPA
Do Something here eg. open program/file command
End If
End Loop
#Shivam,
To get more clarity on your problem statement, you mentioned once that the files are already in PDF.
Are you trying to copy content from PDF to Word? In that case, you could use PDF Integration commands, provided the PDFs are not hand-written or scans. If that is the case, the text extraction might become more unreliable.
A safe bet with Automation Anywhere is to just extract all the text, open a new Word document and paste the content and save file.
Saving all files as word might a little counter-intuitive. You can just use the If statement within your for loop to only process files with "RPA" in their name.
Hope this help. Let us know you go :-)
its pretty simple use includes in your if statement
workbench snapshot

Need help opening printer spool shadow file (.SHD) that is locked

I'm interested in some information inside a shadow file (.shd) located inside the windows print spooling directory "C:\Windows\System32\spool\PRINTERS". Every time a print job is started, a spool file (.spl) and a shadow file (.shd) are created in that directory. So far I have been successful in detecting when a print job has started, and have been able to pause that print job. If you don't pause the job, the files eventually make their way to the printer and then are deleted by windows.
My problem is. I cannot open the .SHD files because they are locked in such a way that you can not read them while they are open by the sprint spooler. I've even tried going to the file in windows explorer and simply copying the file to another file, and that didn't work either. The .SPL spool files I can open though. I simply wait, and fairly quickly the spooler release that file. For the shadow file though, it permanently holds on to this file. Unfortunately, its the one I need.
The line of code I'm using specifically to open the file is as follows:
m_spoolJobStream = new FileStream(spoolFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
The IOException I get is:
The process cannot access the file 'C:\Windows\system32\spool\PRINTERS\FP00083.SHD' because it is being used by another process.
So yes, it is being used by another process. Its being used by the window's print spooler service. But I don't think there is anything I can do about that. All I want to do is read the file. I don't want to make any changes to it. Is there anything I can do here or am I just screwed?
Check the option: "Keep printed documents" (if you have HP printer) and then see your spool file folder, both shadow and spool files would be there.
Well, I did not find a way around this problem. I suspect there is no solution for this and it is by design. However I did find another way to get the information I wanted (at least it seems so thus far).
I'm using the FindNextPrinterChangeNotification() routine out of the winspool.drv library. This guy returns a pointer to a PRINTER_NOTIFY_INFO structure, which in turn contains an array of PRINTER_NOTIFY_INFO_DATA structures. Within that array, there is an element with its "Field" member marked as "JOB_NOTIFY_FIELD_DEVMODE". This element contains a fairly large structure of type DEVMODE. The structure is explained by M$ here http://msdn.microsoft.com/en-us/library/dd183565%28v=vs.85%29.aspx . This structure looks like it contains what I'm looking for and apparently is wrapped up in the .SHD file anyways according to this page http://www.undocprint.org/formats/winspool/shd. I'd like to know what else is in that .SHD file, but I still can't open it because its locked while the job is paused, and I suspect that it stays locked until the job is complete. Oh well, I think my new solution is more elegant anyways.
Just make sure you pause the job in the spool on BOTH your box and the server, then you should be able to copy/open/move the shd file just like you can the spl file. Worked for me, anyway...
This works for me:
- Hang your printer (e.g. jam the paper)
- Print and observe .SHD and .SPL being created
- Stop Print Spooler
- Open the file
The problem might be the FileShare.ReadWrite parameter. You're asking to read and write on the file and maybe that's why you get an error. You should try asking for read-only permission.

Is Modifying the content of a file possible in mqfte using ant task?

I have to substitute the letter "A" with letter "C" in the content of a txt file.
Let test.txt be a txt file. The content is as follows:
Ace Apple
I need the content in the destination folder to be as :
Cce Cpple.
Is this possible in mqfte using ant tasks?
The short answer is "yes."
The longer answer is that you can do anything with Ant that can be scripted, including calling other scripts. The approach would be to use a post-destination call that would edit the file after it arrives. This call won't fire if the file transfer fails. If the transfer succeeds the post-destination call does fire and will run your task or script to edit the file. Just remember that if you configure this to run as a monitor, it will fire on every file transfer. If you want to run it as an ad-hoc transfer you will need to submit it from the command line since the GUI does not support the pre/post calls.

How do I find out the path of the file triggered by opening a file with a custom file extension?

How do i get the location of the file that i used to open my programs with?
Example: if i create a new extention ".xyz" say and i tell windows that i want to open the file type .xyz with myapplication, then it starts my aplication. Great, but how does my application get a handle on the file path of the file that was used to start it?
Also, is there a way to keep just one version of my app running and new files that are opened to just call a method in my application? For example if your using a torrent and you open 5 .torrent files they all just get passed to one application.
Side question: are all file extensions 3 letters long and is there a list of ones that are publicly used? If im creating a file extension I don't want to use one that is already used.
When you created your file association, you specified the command line that Explorer should run to activate your program. The shell puts the name of the document file on the command line, too, so in your program, check the command-line arguments. How you do that depends on your language and development environment. In Delphi, use the ParamCount and ParamStr functions.
When you create the file association, you can specify exactly where on the command line the document file name should go. Use %1 somewhere on the command line, and the shell will replace it with the file name. Since Windows file names frequently contains spaces, you should put quotation marks around the file name, so the command line in the file association would look like this:
ArthurApp.exe "%1"
With that association, double-clicking another document file will start another instance of your program. If you'd prefer to have the document opened in another window of the already-running instance, then you can write code to make your program look for already-running instances when it starts up. If it finds one, then it can communicate with that instance to tell it what file to open. You can effect that communication any number of ways, including mailslots, sockets, named pipes, memory-mapped files, and DDE.
The shell's file-association mechanism already has a way of communicating via DDE, so a second instance of your program wouldn't be started at all. Instead, the shell would start a DDE conversation with the already-running instance and tell it the new file name that way. However, DDE seems to be falling out of favor nowadays, so check out some of the other options first.
For your side question, no, extensions are not always three characters long. Look around, and that should be obvious: C code goes in .c files, Adobe Illustrator graphics go in .ai files, and new Microsoft Word documents go in .docx files.
But beware. If you ask for **.doc*, the results will include .docx files as well. That's because FindFirstFile matches both short and long file names, and long file names with long file extensions have three-character extensions in their short-file-name versions.
Rob covered the answer to your question(s) beautifully.
As to the last part, whether there is a public list of file extensions - not as such, but there is shell.windows.com, the web service Explorer uses to locate handlers for unknown file extensions. You can make up an extension then query shell.windows.com to see whether it's been registered. For example, to check whether the extension .blah has been registered by anyone on shell.windows.com, just open this URL in any browser:
http://shell.windows.com/fileassoc/0409/xml/redir.asp?ext=blah
Of course, replace the trailing blah with your extension.
You can find more details about this in KB929149 and in Raymond Chen's post Where does shell.windows.com get information about file extensions, and how do I get in on that action?.

Resources