Download zip file from Google Drive, unzip it, run CMD script

Hello, Support Team!

We need a script to deploy our custom application packages on the target computers. Those custom application packages are just zip files containing all the required installation files plus a CMD script to install the application with our custom settings. That CMD has to be run with local Admin permissions and is configured to provide a full log of the installation. We use corporate Google Drive to distribute them.

The script has to do the following:

  • Download the single .zip file from the provided Google Drive URL
  • Unzip all the files and folders to a temporary folder.
  • Run the extracted "Install.cmd" script.
Could you please create the requested script?

Thanks a lot in advance for your kind help!

Regards,
– Javier Llorente
Endpoint Security - Devoteam

Hi @DevoteamEndpointSecu,

Thanks for your script request. We have asked our script developers to check and provide update.

Kind Regards,
PremJK

Hi @DevoteamEndpointSecu,

Our script developers are requesting package to test the script, can you please provide us that in private message.

Kind Regards,
PremJK

Hi @PremJkumar !

I’ve just sent you the requested information through a private message.

Thanks a lot in advance for your kind help!

Regards,
– Javier Llorente
Endpoint Security - Devoteam

Hi @DevoteamEndpointSecu,

Thank you so much, we have shared those file to our script developers.

Kind Regards,
PremJK

Hi @DevoteamEndpointSecu,

Please run this script prepared by our script developers and let us know if the script suffices your needs
https://scripts.itarian.com/frontend/web/topic/script-to-downloadextract-run-cmd-file-from-cloud

Kind Regards,
PremJK

Hi @PremJkumar

Thanks a lot for the provided script. We’ll test it and come back with the testing result as soon as possible.

Have a great day!

Regards,
– Javier Llorente
Endpoint Security - Devoteam

Hi @PremJkumar

We have tested thoroughly the provided script. It works fine, but we have a couple of concerns about it:

  1. The script looks for a .cmd script file in all the extracted folder and all the subfolders. Our script is always located in the extracted folder, there is no need to look in the subfolders. This might even be an issue, as we have a couple of packages that have .cmd scripts in the subfolder that are intended to be called by the main script. It seems that the current procedure starts looking for the script in the subfolders, so it could run the secondary script instead of the main one.

We want to change this behaviour, so the procedure only looks for the .cmd script file in the extracted folder (and not in its subfolders). If the developers prefer to make the procedure ask for the script name, for us, it’s also OK.

  1. The output of our script does not appear in the Procedure logs.

We wish to change this behaviour too, so the procedure logs show the output of our script.

Is it possible to do the requested modifications, please?

Thanks a lot in advance for your kind help!

Regards,
– Javier Llorente
Endpoint Security - Devoteam

Hi @DevoteamEndpointSecu,

Thanks for providing your valuable input. We have shared the same modifications with our script developers and will try to provide the updated script.

Kind Regards,
PremJK

Hi @DevoteamEndpointSecu,

Please try this script prepared by our script developers provided in JSON file and provide your input

Note : Change the cmd_file_name variable for the name of cmd

Kind Regards,
PremJK

20210628-install.json (4.06 KB)

Hi @PremJkumar

Thanks a lot for the provided script. We’ll test it and come back with the testing result as soon as possible.

Have a great day!

Regards,
– Javier Llorente
Endpoint Security - Devoteam

Is there any feedback from using this script? I can’t get it to work. I can see that it downloads my ZIP file, then extracts it, but doesn’t run it?
Many thanks,

Stewart

Hi Devoteam!

I am using the script from the url you have provided. I have a ZIP file with a .cmd file inside it, no folders. Uploaded to google drive and amended the procedure line 1 for the download URL (modified Google drive to force download) and then amended line 61 to my own zip file name.

When I run on a test machine, the file downloads and extracts to the ProgramData\extraction folder, but doesn’t run it.

I then receive the following error in the execution log:

Downloaded succesfully to C:\ProgramData\extraction_file\PROTECTAgentInstall er.zip file unzipped to C:\ProgramData\extraction_file
Traceback (most recent call last): File “<string>”, line 96, in <module> TypeError: ‘NoneType’ object has no attribute ‘getitem

I attach the my script in .txt format.

Many thanks!

Procedure.txt (3.18 KB)

I managed to amend the lower part of this procedure to something extremely basic which works for me. I attach the txt file here for those that may require it. The whole proceedure seems a bit overly complex to me, but thats most likely because I don’t code at all in Python. So copied code from other examples and run it on a variety of environments until I had complete sucess. This will download a file to c:\programdata\extraction_file then run your executable from there. I have managed to rollout my agent with 100% sucess rate - thanks!

Updated_Procedure.txt (2.54 KB)