This may be a dumb question with a simple solution but I am trying to incorporate a line in a batch file to silently uninstall a wise uninstaller (it's to uninstall SolidThinking Embed 2017).
There is a shortcut for the Unwise.exe in the same folder to also include the log file from installation, otherwise running it by itself will prompt for a log file, or it throws the error that it cannot find the log if done in the script.
Is there a way to include the log file in the line and also uninstall the application silently?
For example (which doesn't work):
"C:\hw2017\Unwise.exe" "C:\hw2017\VisSimECDWeb150.log" /S
Thanks in advance.
Taken from https://www.symantec.com/connect/blogs/wisescript-command-line-options. Note the final paragraph which has specific instructions for how to specify the log file.
Uninstall Command Line Options
You can apply the following command line options to the WiseScript
Express uninstall executable file, unwise.exe or unwise32.exe.
/Z Removes empty directories, including the one containing Unwise.
/A Automatic mode. The Wise splash screen appears on the destination
computer, and the uninstall proceeds immediately with no end user
choices, except for questions about uninstalling shared files.
/S Silent mode. The uninstall proceeds silently with no splash screen,
no dialogs, and no end user choices.
/R Rollback mode.
/U Removes the Select Uninstall Method dialog, which means the end
user does not see options for a custom, automatic, or repair
uninstall.
When you use command line options for the uninstall
program, you must send it the path to the log file as a parameter. It
must be the log file that is in the same folder as unwise.exe. If the
path to the log file contains spaces, it must be surrounded by
quotation marks.
Example:
"C:\Program Files\Application\UNWISE.EXE" /A "C:\Program Files\Application\INSTALL.LOG" Application Uninstall
I have recently installed a 32-bit program remotely & silently (thru PDQ) that utilizes Wise installer package and uninstalled the same program (via PDQ).
The install was in a batch file using the full file path and its silent switch (/S)
The uninstall was in a different batch file, but contained the short filename scheme (8.3).
So the uninstall path was...
C:\PROGRA~2\YOUR-APP\UNWISE.EXE /S /Z C:\PROGRA~2\YOUR-APP\INSTALL.LOG
/S is silent
/Z is to remove directories including itself
No quotes used since there are no spaces, but it may not hurt if added
Hope this works for someone!
I agree with Bill_Stewart, the vendor needs to answer this for you. However, here's how to find your log:
run regedit
Navigate to HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
Find the AppName.
Examine the "UninstallString" key value
This will give you the log, but doesn't answer how to silently automate it.
Related
Essentially I would like to install an msi file silently, and I've got it to work using the following line:
msiexec /i C:\Users\%username%\Downloads\mysqlODBC.msi /passive
One addition I would like to make is to add double quotes to the user name portion of the line to ensure any usernames that may contain spaces are read correctly. ----> "%username%"
The issue is the msi file fails to install when I add this. I have always used this when writing batch scripts with directories. Any idea how this can be addressed to work with msiexec?
Link to MSI file I am trying to quietly install:
https://dev.mysql.com/downloads/file/?id=484649
Network Installation Point?: It is not quite clear to me what you are trying to achieve. Do you want to automate the installation of this MSI on many machines? If so you should create a network installation point accessible via a UNC path and run an administrative image to extract all files and create a network installation point that can be used for all computers:
msiexec.exe /i "\\Server\Share\Setup.msi" /QN /L*V "C:\Temp\msilog.log"
If you have that instillation point there really is no reason to make a folder for each user. Why duplicate installation files? Surely you don't want each user to download the installer? You would want to download once, malware check and then rely on what you downloaded once and for all?
Anyway, if you insist:
msiexec.exe /i "\\Server\Share\%username%\Setup.msi" /QN /L*V "C:\Temp\msilog.log"
Quick Parameter Explanation:
/i = run install sequence
/QN = run completely silently
/L*V "C:\Temp\msilog.log"= verbose logging at specified path
msiexec.exe: See this answer for some further details on the msiexec.exe command line: MSIEXEC what is the difference between qn and quiet. There are two different flavors of it - two different sets of switches: old style and some newer, "friendlier" versions. I only use the old style switches. There is a tool you can use to generate the command lines.
Some Links:
Customize msiexec progress bar?
How to install an MSI silently
TL; DR :
pushd "C:\Users\%username%\Downloads\"
msiexec.exe /a "mysqlODBC.msi" /quiet /norestart /log "%cd%\msiexec_install.log"
popd
Details :
While the fully qualified path should be able to placed in-between double-quotes, an alternative option would be to use pushd and popd to move to an from the directory containing the MSI.
In the example above, I replaced the progress bar (aka /passive) with /quiet. I also used /a rather than /i out of habit - either can be used to install. And I included a log-to-file option which can be useful in troubleshooting.
I have set a new environment variable pointing to msbuild.exe folder.
C:\temp\Test>echo %DOT_NET4%
C:\Windows\Microsoft.NET\Framework\v4.0.30319
Now, if I start a new cmd and run "msbuild.exe", the programs runs ok, but after running this simple bat, the program is not found anymore:
"C:\Program Files\TortoiseSVN\bin\svn.exe" checkout %CHECKOUT% %PATH%
cd %PATH%
nuget restore OpenText.sln
msbuild.exe OpenText.sln
msbuild not recognized as an internal or external command.
Thanks in advance
I am seeing the same thing as Joey in his comment. Your use of CD %PATH% is a red flag that indicates a problem.
PATH is a critical environment variable that contains a delimited list of folder paths where important executables are located. The command processor uses that list to locate programs when an external command is issued without the full path to the command.
If PATH is set correctly, then your command CD %PATH% cannot work. But I suspect you have some script that defines PATH to a specific folder, perhaps where nuget is located. In this case, your CD %PATH% command works, but now cmd.exe has no idea where msbuild.exe is located.
Moral of the story - don't ever use PATH for your own purposes. Pick some other variable name that is not reserved.
First things first, where are you setting the msbuild path? To resolve your issues, please check if you have followed this process:
Open your system control panel, check for advanced system settings.
Click on Environment variables and edit PATH
Add a semicolon followed by the msbuild path.
Open a new command prompt and check if it is working or not.
Please note if you set msbuild in one command prompt, it will not be available in another command prompt.
Another issue which I see when I look at your logic is, you are trying to cd to %PATH% which should be avoided, you are either resetting the Environment variable path to a new path and trying to cd to it or you will land up file name longer issues, please use another variable instead.
In the bat which you are invoking, add a condition at the root level, such that if msbuild is not found, basing on %ERRORLEVEL%, try adding msbuild to path again at batch level, so that you build will proceed.
I am trying to have a batch file run once when Office is started. I opened the following key and inserted it in there but I am obviously not invoking the right command.
HKCU\Software\Microsoft\Office\15.0\FirstRun
I am inserting the item as C:\program files\Office2013Templates\OfficeTemplate3.bat which will run manually but not run from the registry key.
so the entire string looks like this:
"msofficeTemplate"="C:\\program files\\office2013templates\\officetemplate3.bat
I would also like to run it silent, but one thing at a time.
Thanks for any help you might be able to give me.
If office is using CreateProcess it won't work because it's not a program. CMD.EXE runs batchfiles. So try this command.
C:\Windows\System32\Cmd.exe /c "C:\program files\Office2013Templates\OfficeTemplate3.bat"
Office may require backslashes to be escaped. Registry files require backslashes and quotes to be escaped. But the registry itself doesn't. So enter above in registry editor and export to get properly formatted regfile.
done a search on this, but little joy. I am making and later, trying to delete a folder in the same batch file:
mkdir "%_gameKey%"
:: Stuff.....
rmdir /s /q "%_gameKey%"
I get the error "the process cannot access the file because it is being used by another process." I also can't delete the folder via right-click delete - same error. Interestingly, the rmdir removes the contents of the folder. There is nothing in the folder, nor is there anything obvious accessing it.
I have used Unlocker - shows no processes. Have also used Process Explorer, searched on the folder name (with/without full path) - no search results.
When I restart my machine, I can delete it. Not sure if down to user permissions. I see from this that Users only have Read/write not full control. (sorry - not very good with user permissions stuff - especially on windows!). However - surely it can't be this as I can delete it upon restart.
The folder is on a non OS drive.
I'm stumped - any ideas?
A folder cannot be deleted on Windows if any application uses this folder currently as working directory.
In your case I suppose that the batch file uses command cd to change the working directory to the created directory. So you need to use cd once again to set a different working directory before using command rmdir to delete this directory.
It is of course no good idea to start other applications with working directory being currently the directory which should be deleted later and which continue running on exit of batch file as those started applications have this directory as working directory as well.
I had same issue, after launched a powershell process from a folder via win cmd.
After powershell finished, I cd .. in win CMD but rd /q /s gave error: open in another process
I get same error when manually delete folder in explorer window, even if it was empty.
wmic process revealed that powershell.exe could be locking the folder, even though powershell had finished the task & powershell window had closed.
This was confirmed by tasklist
I then taskkill /im powershell.exe, after which the folder could be deleted.
My word - that was an obscure one, but finally found the answer by stepping through the code putting the rmdir in various places. I post this here in case anyone encounters the same...
Basically, I was calling cmd prompts and launching external exe's whilst in the said folder. Later, I was forcibly closing the exe's with TaskKill, but this was leaving the cmd consoles open at the path of the directory I was trying to delete. I'll try be clearer....
Whilst batch script was in the directory (e.g. C:\Windows\Scripts\Launch), I used the following command:
Start "AppLaunch" Call "!_supExe!" !_supCmd!
Which, after expansion, translated to, for e.g.:
Start "AppLaunch" Call "C:\Windows\Program Files(x86)\Troubleshooter\trbshtr.exe" -game "My Game"
I was using this because, from reading, there appears to be a bug in windows making the following command fail:
Start "AppLaunch" "C:\Windows\Program Files(x86)\Troubleshooter\trbshtr.exe" -game "My Game"
The problem comes when you have to use quotes for both the exe and the parameters (for instance where there's spaces). Windows doesn't read it right. Thus had to use topmost to launch these apps.
Problem being, when used:
taskkill /f /im trbshtr.exe
The exe was killed, but the command prompt wasn't. Using /b on the Start command made no difference.
So, the solution was - cd out of the directory into one that the batch script doesn't alter before launching the other apps via the above. Job done....
Now that just leaves me with how to close all those opened cmd windows (or those in taskmgr if I use the /b switch). That's probably a topic for another search or thread!
I have a exe file created via IExpress. This file contains 1 msi file, 1 setup.exe file and a batch file with those commands:
C:\Windows\System32\msiexec.exe /i pitming.msi /passive
setup.exe
When I manually launch the batch, everything runs fine. But once I put everithing in the exe, nothing happen. So I'm trying to find what is wrong, but I don't know where to find a log file containning the error.
Can someone help ?
Thx,
If you want the log out of the MSI you need to edit the line to:
C:\Windows\System32\msiexec.exe /i pitming.msi /passive /l*v %temp%\pitming.log
and you'll at least get some logging out of it.
What command are you using to launch the batch file? You might find that you need to make the post install command to be:
C:\Windows\System32\cmd.exe /c mybatchfile.bat
As far as the setup.exe goes, that probably has its own logging options.