Windows software install automation - batch-file

I am trying to automate the task of installing a software on Windows 7 and its an .exe file which requires user input in the form of Next or Ok. I have to first push that .exe (WinampInstall.exe) file on to the machines (over 100 of them). Additionally it should run silently without requiring any input from the user.
Until now I have come across AutoIt which can create macros which can replay the actions of the mouse and keyboard. I'm having trouble with the .au3 script, as it doesn't fully automate the installation.
Can I use batch file to run the script as well?
Run('C:\Users\Desktop\WinampInstall.exe')
_WinWaitActivate("SciTE","Address: C:\Program ")
MouseMove(630,19)
MouseDown("left")
MouseMove(609,-150)
MouseUp("left")
MouseMove(301,9)
MouseDown("left")
MouseMove(578,-18)
MouseUp("left")

According to the WinAmp forums, you can use command line switches with the installer.
winamp50*.exe /S /install=SFQDRA
/S = Silent install
S = start menu icons
F = file association
Q = quicklaunch icon
D = desktop icon
R = fake registration
A = run winamp agent/set default
An example batch-file using command-line switches that would
Copy the WinAmp installer from a network share
Install WinAmp silently (using the /s switch)
#echo off
set "localPath=%temp%\WinampInstall.exe"
copy "\\network-share\WinampInstall.exe" "%localPath%"
"%localPath%" /S
pause

Related

How to run Unwise.exe silently while specifying log file

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.

Removing a shortcut with a batch file on a windows 8.1 desktop deployed through sccm

I have a question that has eluded me for a little while. I am deploying a script with sccm and it installs a couple of programs and is supposed to remove a shortcut from a users desktop.
The trouble I'm having is that everything deploys fine but the shortcut doesn't get removed.
When I run the batch file locally on a test computer it removed it fine.
Can someone please help me as to why it doesn't want to get removed when i deploy it through sccm?
Here is my code for the batch file:
:: Installs refresh app
\\server\program.exe" /VERYSILENT
:: Removes shortcut
del /F /Q "%USERPROFILE%\desktop\shortcut.lnk"
:: Adds new software
xcopy "\\server\program1.exe" "%userprofile%\desktop"

can't delete folder from batch - folder or file open in another program

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!

Execute windows batch command from Jenkins fails but runs fine in cmd.exe

I am trying to run this command in jenkins after a MSbuild
xcopy "C:\Program Files (x86)\Jenkins\workspace\trunk\Projects\results\results\obj\Debug\Package\PackageTmp" "Y:\Extraction_Zone\Jenkins\" /E
Y: is a mapped network drive. This runs fine in cmd.exe but when trying to run it in Jenkins, I am getting the error Invalid drive specification.
Here is the output from jenkins:
Time Elapsed 00:00:04.03
[trunk] $ cmd /c call C:\Windows\TEMP\hudson3389873107474371072.bat
C:\Program Files (x86)\Jenkins\workspace\trunk>xcopy "C:\Program Files (x86)\Jenkins\workspace\trunk\Projects\results\results\obj\Debug\Package\PackageTmp" "Y:\Extraction_Zone\Jenkins\" /E
Invalid drive specification
0 File(s) copied
C:\Program Files (x86)\Jenkins\workspace\trunk>exit 4
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
Any help would be appreciated.
I too had a similar issue once. Try granting the Jenkins service "Logon as This account" right under services.msc and make sure the account you type there is the same as the one you use for running cmd.exe.
These commands based on Java JAR files worked for me:
cmd
net use x: \\
xcopy "dist\" x:\ /Y
And that's it! I spent lot of time figure out this issue and nothing worked until I wrote CMD and NET USE!
Neither I didn't need to change permission on jenkins service nor use runas command.
But I must mention that everyone had read and write access to the network drive.
I had the same issue with my Windows Task running a batch file (I know it is not exactly same) where I tried to copy file to network location i.e. shared drive. I used the UNC path and mapped drive as well but the error was same. For me it was error number 4 - MS DOS error code.
The solution was to use net use command! Hope that it helps.
Easy fix for most things.
Make a batch command with what your trying to run, filename.bat with the command prompt text inside.
Make a normal windows shortcut for the batch command, edit the shortcuts advanced properties and check the "Run as admin" (tricky tricky).
Now run the filename.lnk shortcut from jenkins command line call, this will get you around all the jazz.
:)
The solution of adarshr (i.e., modifying the log on credentials of the service) has worked for me for a part of the problem: in my case, this allowed me to successfully check out a mercurial repository (using ssh protocol), which I could not do when using 'Local System account'.
However, I still have different behavior between running a command-line script or running the same script from a jenkins 'execute shell' script in the build section. In my case, I compile a Python extension. In Jenkins, I cannot import the extension (I don't see any error, but the execution simply stops, so I suspect it crashes).
If I uninstall the service and run the slave agent as a Java Web Start, I do get the same behavoir. It is a temporary fix for me, but it means that when I reboot the windows build machine, I have to manually re-start the Java Web Start application.
So -at least in my case- it is clear that this is a credential problem.
Credentials usage documentation: https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI
I've solved my issue with the CIFS plugin.
Faced similar issue and found two ways to solve.
Type 1:
Tell Jenkins about mapped drive.
1.Goto -> Manage Jenkins -> Script Console (Groovy Script).
2.Run below command
def mapdrive = "net use Y: \\\\copy_nework_address"
mapdrive.execute();
println "net use".execute().getText()
Type:2
1.Goto -> cmd -> run "net use" to know network address
xcopy "C:\Program Files (x86)\Jenkins\workspace\trunk\Projects\results\results\obj\Debug\Package\PackageTmp" "Copy_Network_Address\Extraction_Zone\Jenkins\" /E
Conclusion:- I prefer 2nd types as after every restart i should run Groovy Script.

Windows: script/program for USB key that opens a console, and sets the path and the working directory

The goal behind this question is to create a portable Windows script/program that would help users run (console) programs directly from a USB key (not necessarily through autorun, though). The script/program would thus do the following when double clicked on:
Launch a console (cmd would do) and give a DOS command prompt,
Have the current directory set to a specific directory WorkingDir on the USB key (which contains various [Python] programs),
Set the path so that the user can run a command (python.exe) found in another USB key directory (so that the user can launch various Python programs found in WorkingDir).
The whole thing is based on Portable Python, which is on the USB key. I would also like to be able to simply put the contents of the key on a hard drive and use it from there.
I tried to write a file that contains commands like:
PATH=..\"Portable Python 2.7.2.1\App":%PATH%
cd WorkingDir
cmd
but I'm not sure how to call it so that Windows runs it (and I was therefore not able to see whether these command would work).
I don't know much about DOS and Windows, so any help would be much appreciated!
Actually, in windows you use ; for separating paths :) And you shouldn't use .. like that. You can use %CD% to get current directory and then navigate from it. And don't use quotes. Also, you could put # before any command that you don't wish to be echoed to the console.
You can put this into run.bat (this should work :P):
#PATH=%PATH%;%CD%\..\Portable Python 2.7.2.1\App
#cd WorkingDir
#cmd
And then just double click it and it will open commmand prompt just as you want it. Or maybe you can add autorun.inf file to open it automatically.
You need to create two files:
autorun.inf
[autorun]
open=cmd.exe "Python Console" /k autorun.cmd
action=Open Python Console...
autorun.cmd
#Echo Off
CD %~d0\WorkingDir
Path %Path%;%~d0\Portable Python 2.7.2.1\App
The phrase %~d0 represents the drive the command file resides, namely the flash drive's letter (E:).
Now, I encountered two slight hiccups. My USB drive had a hidden, system, readonly autorun.inf file on it already. I had to unprotect it with the following command before I could edit it.
Attrib autorun.inf -r -s -h
My second hiccup, is that Windows 7 won't autorun from a USB drive. You have to right-click the drive in Explorer and select "Run Python Console..."

Resources