My 7-zip is installed in
C:\Program Files\7-Zip
and my source log file location is
E:\OracleGrid\11.2.0\grid\log\diag\tnslsnr\enctcorl010\listener\trace\listener.log
There is only one log file in there. I want to zip it by renaming name like current date LISTNER_DDMMYY.ZIP to new destination to
E:\DBA_CMDS\Maintenance_Tasks\ClearListenerLog\ArchivedListenerLogs
I would appreciate if someone can help me to write in batch script since I am new to this script. I appreciate your help.
Try this:
#ECHO OFF
"c:\program files\7-zip\7z" a E:\DBA_CMDS\Maintenance_Tasks\ClearListenerLog\ArchivedListenerLogs\listen_%date:~7,2%%date:~4,2%%date:~12,2%.zip E:\OracleGrid\11.2.0\grid\log\diag\tnslsnr\enctcorl010\listener\trace\listener.log
IF ERRORLEVEL 0 DEL E:\OracleGrid\11.2.0\grid\log\diag\tnslsnr\enctcorl010\listener\trace\listener.log
This assumes that the 7-zip command line has been installed in the 7-zip directory you mention. It is a separate download / install.
HTH.
Related
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
Looking at example on WinSCP forums, I am able to put together a .bat file and associated .txt file, which works ONLY if both files are located under the same location as where WinSCP.com (and other WinSCP related files) is located:
C:\Program Files (x86)\WinSCP
Is there a way to run my .bat file successfully without having it under:
C:\Program Files (x86)\WinSCP
My .bat file content:
winscp.com /script=recon_SFTP.txt
pause
I did try moving my .bat file and .txt file to another location and adding location path, but it didn't work. I am guessing I need to escape spaces from my file path to location winscp.com?:
C:\Program Files (x86)\WinSCP\winscp.com /C:\Users\sqlservice\Desktop\SSmith1\script=recon_SFTP.txt
pause
Just use a full path to the script file after the /script= switch.
And of course, you have to quote paths that contain spaces, like the path to the Program Files (x86).
"C:\Program Files (x86)\WinSCP\winscp.com" /script="C:\Users\sqlservice\Desktop\SSmith1\recon_SFTP.txt"
Though if the .txt is in the same directory as the .bat and you execute the .bat from its folder, you do not have to use a full path to the script:
"C:\Program Files (x86)\WinSCP\winscp.com" /script=recon_SFTP.txt
Enclose any string conaining spaces that you want to be treated as a single string in "double quotes"
You could also add the WinSCP installation directory to your PATH. Then you can call winscp.com from any directory.
Add directory to path
I want to run .exe files from a folder using batch file, here assume that I have n number of .exe files, so on one click I want to execute all .exe files without specifying each .exe file in the batch.
for %%a in ("c:\somewhere\*.exe") do start "" "%%~fa"
For each file in the indicated set, execute it.
See for /? to get help on the command usage.
We need to run a .msi file from batch file which is working fine if the path of .msi file is hard coded in batch file. Is there any way to get the path of .msi file dynamically as the batch file and .msi file exist at same folder location? It will really solve the purpose as thses needs to be copied to multiple servers...
%~dp0install.msi
%~dp0 gives you the path of your bat-file.
(note, that the last backslash is already included.
try #echo %~dp0 in your batch-file)
If the batch file and msi file are in the same folder then no path at all is needed. The batch file defaults to the current directory - and will write the log file to the current directory.
This is only an issue if the batch file is launched from a network drive.
I want to make a Batch File (.bat) to install an .inf file that is located in the base directory of the .bat file. I managed to install the .inf, but only if I specify the full directory. How can I install the .inf file without specifying the full directory?
Here's what I have so far:
%SystemRoot%\System32\InfDefaultInstall.exe "DroidInstaller.inf"
Any help would be greatly appreciated.
Your question is quite vague. If both files (your installer.bat and the inf file) are in the same directory then you can add pushd "%~dp0" at the start of your batch-script:
#echo off
pushd "%~dp0"
%SystemRoot%\System32\InfDefaultInstall.exe "DroidInstaller.inf"
This will set the working directory to the directory where your batch-script runs in. If this directory is the same as the directory of your inf file then you are able to call the DroidInstaller.inf the way you did in your question.