How do I run a batch file once in Office 2013 - batch-file

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.

Related

Command Line Installation with SCCM 2012

I have a few applications that I am trying to deploy with SCCM 2012 but the installations are failing through the application catalog. So what I have for the deployment type is a script installer. I have "cmd.exe" (Without quotations) in the Installation program field and "Installer.bat" in the installation start in field.
When I look at the ccmcache folder, all the contents over that application are there but the following error displays the Software Center:
0x8007010B(-217024629)
I have done some reading online and the "10B" is a common command line error for invalid directory. I have tested the batch file when hard coding a path but my question is, how can I edit the batch file or SCCM to pull from the CCMCache path where the files are downloaded to on the local client? Currently the Batch File is simply:
#echo off
ApplicationName.exe
Do I need to edit the file to cd into the CCMCache folder where the files are placed? How can I get the batch file to run the executable that is downloaded to the CCMCache folder?
Thank You!
You need to have the full path to the installation in your script
#echo Off
\\path to .exe
The way the command is written will not be able to find the .exe file. You need to add the full unc path to the .exe into your .cmd file. You should have your installation .exe and .cmd file in the same location on the distribution share
Recommended Solution:
Before starting, since you are only launching an exe with your batch file, I would recommend just using your ApplicationName.exe as your command line parameter in SCCM instead of using a batch. This will eliminate the need to engineer any further.
Modifying the existing solution to work:
If you do still want to use a batch file, keep a few things in mind. The syntax you are using to launch the batch file will not work. I would recommend just using the batch file name "installer.bat" as your command line. If you still want to preface the batch with the cmd.exe, you absolutely need to use the /c switch with it
cmd.exe /c installer.bat
If you don't use /c the console host will only open to a promopt and not execute your batch.
This is not an ideal solution though because using "cmd.exe /c" will set your working directory to the location of cmd.exe (ie "C:\windows\system32") and since your content is staged in ccmcache, you will need to specify its location within your batch. To do this, you would use %~dp0 variable which gives you the directory the current batch is running from. This means modifying your batch to read
#echo off
%~dp0ApplicationName.exe

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.

Starting a server using start "" "%~dp0\server.exe", parameters being ignored because of spaces

START "Test Server" "%~dp0\server.exe" LAN %M%.aao log=server.log ini=server.ini
Everything after "LAN" is not being executed by server.exe I can see in the servers log file that it is trying to open lan but it should be trying to open %m%.aao which means everything after "LAN" is being ignored.
How can I fix this?
Using
START "Test Server" server.exe LAN %M%.aao log=server.log ini=server.ini
will not work as I'm trying to run the batch file from WOTGreal. I am unsure why, but the way I fixed it for the other two files/programs I open was to use %~dp0, but the server requires that the spaces not be ignored.
I'm trying to run the batch file from WOTGreal
So the batchfile will be run from a different folder. That will also mean server.exe will be run from a different folder. so local filenames like in %M%.aao log=server.log ini=server.ini will be read from the wrong directory.
You could probably fix that by also using %~dp0 in all other paths. But it is probably easier to change the current directory at the start of the batchfile. To do that, add the following line to the start of the batchfile.
cd /d "%~dp0"

Jenkins coping with spaces in batch file arguments

I'm setting up Jenkins on Windows to take care of the builds for a Windows project I've been working on. Until now, I've just been building locally. I've got a batch file that performs the build, which ends up generating some msi installers.
Some of the projects contain post builds steps that run batch files. The arguments to the batch files sometimes contain spaces. This isn't a problem when I run my build batch file from the command prompt.
However, Jenkins seems to have a problem with this - I get errors such as
"File not found: C:\Program"
I'm puzzled as to why the error happens when Jenkins triggers the batch, but not when I run it manually - any ideas?
For arguments that include spaces, wrap them in double quotes. Example:
WRONG: PROCESS_FILE.EXE C:\Program Files\This File.txt
CORRECT: PROCESS_FILE.EXE "C:\Program FIles\This File.txt"
As Jason mention, you need to pass your arguments and paths with quotes.
Also, check the build log and see which type of quotes you're using. Depending on where it's being passed you may need single or double quotes, or some sort of escape character.
If you want to look at the actual batch file that Jenkins runs for your external commands or pre/post build events, check the build log and load up the temporary batch file in an editor to see what it actually looks like. Sometimes this is necessary to debug your build.

Where can I find output log file of a setup generated by IExpress

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.

Resources