Batch install to specific location - batch-file

I was having trouble after creating a windows service in c# with creating a silent install with a batch file or w.e. is needed that takes in just the location of the install, as when I run setup.exe or the msi file that is all that's in there. It will prompt to change location if desired, otherwise go to default C:\drive folder that is preset within the service, no other options are required.
I was wondering how to use a iss file or an answer file to create either a cmd prompt or script to mass install on many computers easily.
Currently setup.exe accepts in the cmd setup.exe /quiet instead of what I have been seeing -s or /s which also had caused some confusion and to why I was looking for help. Thank you.

Ok. I typically use InstallShield for that. If you are doing this in pure batch, then you will need to take steps to configure/start the service. See SC /?. That will allow you to query the service, stop, start, etc. Give it a try and reply with more specifics if needed.

Related

Get installation path of program installed by window installer but not seen by command line "where"

I have an Interop Excel application, installed via Window Installer, which contains only .dlls and no executables/.exes. It is seen by both "Add/Remove program" and wmic product get name listing but not by the command where (refering to here).
I am writing a batch file to modify some files after installation. How can I get the installation path of this program in my batch file?
I should also mention that although "Add/Remove Program" sees the program, it does not exist in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
It's my guess that you won't be able to find out because the install path is not automatically recorded in the uninstall registry info unless your setup set the ARPINSTALLLOCATION property:
https://msdn.microsoft.com/en-us/library/aa367589(v=vs.85).aspx
or you explicitly created a registry item and set its value to [TARGETDIR] which is what you could do in future if you want to save the location somewhere under your control.
So Chris's answer is likely to be the correct method for finding a path, and also correct in telling you not to replace files. Installer resilience (or a repair from Add/Remove Programs or right-click on the MSI file-repair) is likely to restore them, requiring the original MSI. MSI knows the file versions of what was installed. In addition, an upgrade or a patch may also need the original MSI. Caveat Emptor.
Use WMIC's where to specify the name to look for and get InstallLocation to show the path:
for /f "delims=" %%a in ('
wmic product where "Name='Exact name of your app'" get InstallLocation ^| find "\"
') do set location=%%a
The WMI provider for MSI has always been buggy. I'd use the native MSI API to ask it where the components are installed. (MsiGetComponentPathEx function)
But I have to advise that MSI likes to "own" it's files. If someone does a repair it's very likely that your modifications will be history. I'd advise transforming the MSI to contain the modified files and skip the post install modification step. Either that or redesign your addin so that you can have a base set of values installed by MSI and an override set of values copied outside of MSI that MSI doesn't know about.

Possibly to run silent and verysilent from within the application

Is it possible to run the silent and verysilent option from within the inno setup application.That is as soon as I clicked the exe it will run with verysilent option (no need to provide it in the command prompt)
I have figured out the temporary way of putting the command with verysilent option in the batch script and clicking the batch script :) !
It is Bad Formâ„¢ make a "covert" installer. From Inno's FAQ:
Is it possible to do a silent install without using the /SILENT or /VERYSILENT command-line parameters?
No, nor is such a feature planned (it would be abused). If it is your intention to keep user interaction to a minimum, use the Disable* [Setup] section directives.
This would only matter if you are actually building the installer. If you're just trying to install the application, the only sensible thing to do is use the command-line flags in a batch file (or other scripting language).

Failed to update database becase the database is read only

I have created a winform application and programmatically trying to attach the database when an application runs first time. Unfortunately in windows 7 i always got an error. Please view the screenshot below it tells the whole story. Now my question is that how can i get rid from this error, is there any way to automatically give required rights on the folder where the application installs?. I want to permanently resolve this error and need smooth attachment. Anyone please help.
Please view the error below. Thanks in advance
Try ALTER DATABASE MyDatabaseName SET READ_WRITE
More informations here on This forum
Edit
This was asked by someone else
If you put your database in your own subdirectory of the directory returned by Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData then the user will have read/write access to it.
See Environment.SpecialFolder Enumeration to determine if a different location would be more suitable, e.g. ApplicationData if you need it to roam or CommonApplicationData if you need all users of the computer to use it.
Edit: I found a slightly more extensive version of this answer: Where Should I Store my Data and Configuration Files if I Target Multiple OS Versions?, please also see the articles it links to.
I know this answer is somehow late, but I believe people always face the same problems so my case is worth to be shared.
tl;dr = Change the permission of deployed files manually or using icacls command.
Actually I use InstallForge for packing and deploying my application(s).
No matter what setup creator is used, when the application is installed to a non-system folder ( e.g. D:\ ) the program works perfectly and the database is readable/writable.
Whereas when the application is installed in [Program Files] folder or [Program Files (X86)] folder, Windows takes a preventive security measurement and sets file permission to be only [Read] and [Read & Execute].
I think Windows Vista and later versions of Windows have this behavior.
You can check that by right-clicking the installed file and going to properties then Security tab.
The files I installed on D:\ had Full-Control permission while, as I mentioned, the ones on C:\ had only Read & Execute permissions.
You won't notice the difference when you install a normal program on C:\ because you might not be writing data on a file or a database. But in case of database deployment, the file has to be writable.
Finally, the solution for this case was telling InstallForge to change file permissions at the end of the installation using icacls commands :
icacls "C:\MyApp\MyDB.mdf" /Grant Everyone:F
icacls "C:\MyApp\MyDB_log.ldf" /Grant Everyone:F
In my case, it is okay to give everyone full-control on the database files, but you might need a customized solution for your case so please refer to :
http://ss64.com/nt/icacls.html
You can tell your setup creator to run those commands, or you can put them together in a batch file and run it after the installation.

Batch file not working when running in the background - issue with substituted drive

I'll try to keep this short, without all the details of this batch file procedure.
OS: Windows XP
Action: Scheduled Task (background, I can't find a way to run it in the foreground)
Problem: files not created on mapped drive. When the batch file is ran directly, it works.
It does the following (or at least tries to):
clean a directory: works
create executables based on a substituted location
We use the following to map a local folder to the K: drive:
subst K: /D
subst K: D:\Development\SVN
The executables are built from source code that is located on (for example) K:\Sources to K:\Executables.
This fails, for a reason I did not yet discover. As mentioned above, if the batch file is ran directly it doesn't fail. If I substitute K:\ by C:\Development\SVN the issues seem to be resolved but still, this doesn't solve the fact that I can't run it when using K:.
I hope anyone here has an idea, I tried Googling for a long time + scanning SO but to no avail.
Thanks in advance!
substed drives are local to session, and your scheduled task is run in another session then your login session.
It seems to be possible to schedule task for user login session with schtasks.exe command line, but then the task runs only if the user is logged in. It might not be what you want, so using a full non-substed path might be the best solution after all.

Batch file to install software silently (or without user interaction)

I am trying to make batch file for installing software silently. Is there a way to make it automatically select Next and Finish during the installing process?
We need more details to answere your question. what is exactly sw?? is it shockwave player, in this case follow these instructions http://kb2.adobe.com/cps/195/tn_19572.html by adding the /s argument.
Usually with most programs you can add the command /silent or /verysilent when installing them through the command line. I know this works with UltraVNC. If it is your own program then you would have to add that option using Inno Setup or something like that.
If the application does not support silent installation, you will need to look at something like AuotIt. You can use it to automate pressing buttons and entering keystrokes.

Resources