Help writing automated script!

Associate
Joined
16 May 2006
Posts
1,415
Location
Copenhagen
I've been asked to write a script that automatically downloads, installs and runs a .exe file.

My programming knowledge is very limited, but I know what I would like to happen and was hoping someone can point me in the right direction.

I want this to run on Windows, and make a check for 32/64 bit and then download the corresponding file from a URL. I assume an IF statement can handle this?

The application is in an Installer package, so was hoping I can run the install with a parameter that can handle it unattended "/qn" or "installer.exe --mode unattended" for example?

The last part of the installer then asks to run the program so should be handled by the above, correct?

I'd rather do this myself and understand each step than simply copying and pasting. Any help would be great!
 
Thanks for the replies so far, a friend mentioned I should look into Powershell instead? Thoughts?

Which version of windows?

It kinda depends on what the installer is set up to do. As far as I know theres no way to run an installer in silent/unattended mode unless the package has been built with that in mind.

I think a use case might be appropriate to give a better answer.

-Windows 10 32/64 bit
-Interesting point, how can a script handle this instead then?
-The case I have been given is to download an application, install and then run it. The application is for atomic modelling but I doubt that's relevant. Its more a test of how it can be done. Could be quick and simple or a bit more complex and more flexible...
 
The program is free, it's simply intended to be downloaded onto a single machine and then run to install and launch the program. Perhaps the script can also check if the program is already installed, but simply installing and launching would be great.

The program is here:
http://quantumwise.com/products/download (The red section with 'VNL')

The installer was configured in house, but I'm not able to change the configuration of that at the moment.

Thanks in advance!
 
Right I've tried the silent installation and unless there's a switch I'm missing it's just not set up to do it. I think there's a way around it but cant find it atm.

Using CMD and running the installer with "--help" it tells you which modes are enabled. Luckily "--mode unattended" was available and can be invoked in PowerShell.

Right otherwise simplest way I can think of would be to do an if/else check on if program files(x86) folder exists if it does then you've got a 64 bit machine if not it's 32 bit. Will remove the occasionally random returns of wmic queries. AFAIK theres never going to be an instance where the program files (x86) doesn't exist on a 64bit version.
http://steve-jansen.github.io/guides/windows-batch-scripting/part-5-if-then-conditionals.html

I used an If check on ([System.Environment]::Is64BitProcess) as I think it is more reliable than the folder check. The program installs to Program Files (x86) regardless of installer version (32/64 bit).

Thanks for the help to everyone so far! One last thing I'd like to add is downloading the files over HTTPS, but I'm running into an error:
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
 
Back
Top Bottom