How can I automate openssl in windows? - windows

I am using OpenSSL (from https://slproweb.com/products/Win32OpenSSL.html) to decrypt a file retrieved from external sftp site. The external site is publishing new files daily, each with new filenames. At the moment when the file is downloaded I have to manually go into Openssl.exe and type the following each time
C:\OpenSSL-Win64\bin\openssl.exe cms –decrypt –inkey C:\key.pem –recip C:\cert.pem –inform DER –in \\server01\filename.xml.crypt –out \\server01\Decrypt\filename.xml
I tried putting this in a batch file (*.bat) but when I ran that it did not work. The only thing that I have managed to get to work is the manual process described above.
Is there a way to automate this and avoid having to manually type the whole code above? I should mention the filename.xml.crypt is actually normally around 100 characters long...
Ideally looking at a windows batch file, or something similar?
Sorry if this is a stupid question!
TIA
Hamez

I'm also having the exact same issues. The hyphen '-' is being converted to the accented u (i.e. -recip, -inform etc). No doubt we've all copied it from a webpage and that has altered the code base of the hyphen. I've just manually inputted the - for all the command line parameters and now it's worked.

Related

Why can this Batch script decode Base85 and extract the corresponding files, and how does it work?

I found a Batch script on Github that installs NSudo, and when I opened it up to see how it works, I was shocked that there was a lot of Base85 encoding in it. I actually know that certutil in Windows can store arbitrary files as Base64-encoded text files, but this script does not use certutil. I tried to read how this script works and found that it uses findstr to locate those Base85 encodings. But due to my limited level, I didn't find out how it decodes Base85. So hopefully someone on StackOverflow can help me understand this script. Thanks a lot.
URL of this script: Github

clean csv file from hidden characters

I work with CSV files and upload them to an S3 server.
Sometimes after a small process that I did with the file I get hidden characters to look like this  before the first columns, I want to write a script that "clean" the files before upload but I can see those characters only on specific text editors like nano, the python didn't recognize those characters and I can see them in Amazon Athena after the query was created already and I need to upload it again.
Does anyone know a solution to this problem?
After a small research I learn that the symbol called BOM and they added to the files because I added encoding='utf-8'.

Cannot be Compressed because it includes characters that cannot be used, but I don't have any files with special characters

So I'm trying to compress some documents I made when I get the following error message:
I have no idea what the character is, as it just looks like a blank space. I have removed the blank spaces from my documents and it still won't let me zip it. Online answers seem to refer to needing the change the language setting on my computer, but I haven't written any foreign languages. Any help would be appreciated.
Go to Users directory and make a new directory called 'Analytics',
Then, move you 'Account_Over_Time_Analysis' to this folder and try to comporess again.
If it fails again, please try 7zip incase your using something else.
Such an error could be caused from different language dir-name, a name with spaces or a name with escape chars.
To fix this you could hunt around for the correct language pack, or just install 7-Zip and use that to zip the files instead

How to Embed/Wrap the VB Script into Exe and Extract during the run time

I would like to convert the VB Script ( .VBS file) into EXE. If any one has any idea on how to convert VBS to Exe, Please share with me.
Some VBS IDEs allow this by default (vbsedit is one example) and there are also lots of tools that would do the conversion I even found a web page for that purpose. The list is quite long, if you google vbs to exe you will find many more.
Please keep in mind that this is not a compilation. Most will either pack the scripting host and the exe together or even just be the vbs file in a self extracting archive (you could also do this yourself with 7zip e.g.) This means the code will probably still be easily obtainable so it is not save to use this with cleartext passwords.
I also found this tool which claims to encrypt/obfuscate the script, but I cannot say how secure it really would be.
As a side note: If you encrypt the script any error message will be with the completely wrong line number, which confused some people I know who used these methods. So for debugging always use the original script.

How to zip a file in windows shell without vb script and with Window default zip only

Is their a way to zip a file without VB Script.I got a lot of examples on web to zip file or folder using vbs but i want to do it in a single BAT file.
Yes and no. There is no built in way to do this inside windows. You can use a external application like vbscript, a exe file like 7zip, rar, lots of resources can do this. Since windows is application poor when it comes to command lines is not really surprising. But no you do not need the VB Script for anything.
Just not so easy out of the box. Maybe makecab could do it for you? As a general rule you have a hard constraint in your question. A single BAT file which in general can not do almost anything without the support of hundreds of preinstalled or commonly installed other applications.
Could you specify a the constraints a bit better. Tel WHY you need this particular constraint? And what does it mean as even most of the bat command you use require more than one file.

Resources