Repository: stbrenner/SilentCMD
Branch: master
Commit: 2541b13f8372
Files: 22
Total size: 49.1 KB
Directory structure:
gitextract_5t7vmtsf/
├── .gitignore
├── Brenner.SilentCmd/
│ ├── ArgumentParser.cs
│ ├── Brenner.SilentCmd.csproj
│ ├── Configuration.cs
│ ├── Engine.cs
│ ├── LogWriter.cs
│ ├── Program.cs
│ ├── Properties/
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ └── app.config
├── Brenner.SilentCmd.Tests/
│ ├── Brenner.SilentCmd.Tests.csproj
│ ├── ConfigurationTest.cs
│ ├── Dummy.cmd
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ ├── TestDelay.cmd
│ └── packages.config
├── LICENSE
├── README.md
└── SilentCmd.sln
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.vs
bin
obj
Debug
Release
*.DotSettings
*.user
*.suo
packages
================================================
FILE: Brenner.SilentCmd/ArgumentParser.cs
================================================
using System.Globalization;
namespace Brenner.SilentCmd
{
public static class ArgumentParser
{
public static bool IsName(string arg, string name)
{
return arg.StartsWith(name, true, CultureInfo.InvariantCulture) &&
(name.Length == arg.Length || arg[name.Length] == ':');
}
public static bool TryGetValue(string arg, string name, out string value)
{
if (IsName(arg, name))
{
int startPosition = name.Length + 1; // +1 because of colon separator
value = arg.Substring(startPosition).Trim('"');
return true;
}
value = null;
return false;
}
}
}
================================================
FILE: Brenner.SilentCmd/Brenner.SilentCmd.csproj
================================================
Debug
x86
8.0.30703
2.0
{461E6475-6450-40ED-B68C-7F012701E6C6}
WinExe
Properties
Brenner.SilentCmd
SilentCMD
v4.8
512
publish\
true
Disk
false
Foreground
7
Days
false
false
true
0
1.5.0.%2a
false
false
true
true
bin\Debug\
DEBUG;TRACE
full
AnyCPU
bin\Debug\SilentCMD.exe.CodeAnalysisLog.xml
true
GlobalSuppressions.cs
prompt
MinimumRecommendedRules.ruleset
;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets
;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules
false
bin\Release\
TRACE
true
true
pdbonly
AnyCPU
bin\Release\SilentCMD.exe.CodeAnalysisLog.xml
true
GlobalSuppressions.cs
prompt
MinimumRecommendedRules.ruleset
;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets
false
;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules
false
ResXFileCodeGenerator
Resources.Designer.cs
Designer
True
Resources.resx
True
Designer
SettingsSingleFileGenerator
Settings.Designer.cs
True
Settings.settings
True
False
Microsoft .NET Framework 4.8 %28x86 and x64%29
true
False
.NET Framework 3.5 SP1
false
================================================
FILE: Brenner.SilentCmd/Configuration.cs
================================================
using Brenner.SilentCmd.Properties;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
namespace Brenner.SilentCmd
{
public class Configuration
{
public bool LogAppend { get; private set; }
public string LogFilePath { get; private set; }
public long MaxLogSize { get; private set; }
public string BatchFilePath { get; set; }
public string BatchFileArguments { get; private set; }
public TimeSpan Delay { get; private set; }
public bool ShowHelp { get; private set; }
public Configuration()
{
LogAppend = Settings.Default.DefaultLogAppend;
LogFilePath = Settings.Default.DefaultLogFilePath;
MaxLogSize = Settings.Default.DefaultLogSize;
BatchFilePath = Settings.Default.DefaultBatchFilePath;
BatchFileArguments = Settings.Default.DefaultBatchFileArguments;
Delay = Settings.Default.DefaultDelay;
}
public void ParseArguments(IEnumerable args)
{
var argumentsBuilder = new StringBuilder();
var batchFilePathWasRead = false;
string argValue;
foreach (string arg in args)
{
if (ArgumentParser.TryGetValue(arg, "/LOG+", out argValue))
{
LogAppend = true;
LogFilePath = argValue;
continue;
}
if (ArgumentParser.TryGetValue(arg, "/LOG", out argValue))
{
LogAppend = false;
LogFilePath = argValue;
continue;
}
if (ArgumentParser.TryGetValue(arg, "/LOGSIZE", out argValue))
{
MaxLogSize = Convert.ToInt64(argValue);
continue;
}
if (ArgumentParser.TryGetValue(arg, "/DELAY", out argValue))
{
Delay = TimeSpan.FromSeconds(Convert.ToDouble(argValue));
continue;
}
if (ArgumentParser.IsName(arg, "/?"))
{
ShowHelp = true;
}
if (!batchFilePathWasRead)
{
BatchFilePath = arg;
batchFilePathWasRead = true;
continue;
}
if (arg.Contains(" "))
{
argumentsBuilder.AppendFormat("\"{0}\" ", arg);
continue;
}
argumentsBuilder.AppendFormat("{0} ", arg);
}
if (argumentsBuilder.Length > 0)
{
BatchFileArguments = argumentsBuilder.ToString();
}
}
}
}
================================================
FILE: Brenner.SilentCmd/Engine.cs
================================================
using System;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;
using Brenner.SilentCmd.Properties;
using System.IO;
using System.Linq;
using System.Threading;
namespace Brenner.SilentCmd
{
internal class Engine
{
private Configuration _config = new Configuration();
private readonly LogWriter _logWriter = new LogWriter();
///
/// Executes the batch file defined in the arguments
///
public int Execute(string[] args)
{
try
{
_config.ParseArguments(args);
_logWriter.Initialize(_config.LogFilePath, _config.LogAppend, _config.MaxLogSize);
if (_config.ShowHelp)
{
ShowHelp();
return 0;
}
DelayIfNecessary();
ResolveBatchFilePath();
using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo(_config.BatchFilePath, _config.BatchFileArguments)
{
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false, // CreateNoWindow only works, if shell is not used
CreateNoWindow = true
};
process.OutputDataReceived += OutputHandler;
process.ErrorDataReceived += OutputHandler;
process.Start();
_logWriter.WriteLine(Resources.StartingCommand, _config.BatchFilePath, process.Id);
process.BeginOutputReadLine();
process.WaitForExit();
return process.ExitCode;
}
}
catch (Exception e)
{
_logWriter.WriteLine(Resources.Error, e.Message);
return 1;
}
finally
{
_logWriter.WriteLine(Resources.FinishedCommand, _config.BatchFilePath);
_logWriter.Dispose();
}
}
private void DelayIfNecessary()
{
if (_config.Delay <= TimeSpan.FromSeconds(0)) return;
_logWriter.WriteLine(Resources.Delay, _config.Delay.TotalSeconds);
Thread.Sleep(_config.Delay);
}
private static void ShowHelp()
{
Assembly assembly = Assembly.GetExecutingAssembly();
AssemblyName name = assembly.GetName();
string userManual = string.Format(Resources.UserManual, name.Version);
MessageBox.Show(userManual, Resources.ProgramTitle);
}
private void ResolveBatchFilePath()
{
if (string.IsNullOrEmpty(_config.BatchFilePath)) return;
if (!string.IsNullOrEmpty(Path.GetDirectoryName(_config.BatchFilePath))) return;
if (string.IsNullOrEmpty(Path.GetExtension(_config.BatchFilePath)))
{
if (FindPath(_config.BatchFilePath + ".bat")) return;
FindPath(_config.BatchFilePath + ".cmd");
}
else
{
FindPath(_config.BatchFilePath);
}
}
/// True if file was found
private bool FindPath(string filename)
{
string currentPath = Path.Combine(Environment.CurrentDirectory, filename);
if (File.Exists(currentPath)) return true;
var enviromentPath = System.Environment.GetEnvironmentVariable("PATH");
var paths = enviromentPath.Split(';');
var fullPath = paths.Select(x => Path.Combine(x, filename))
.Where(x => File.Exists(x))
.FirstOrDefault();
if (!string.IsNullOrEmpty(fullPath))
{
_config.BatchFilePath = fullPath;
return true;
}
return false;
}
private void OutputHandler(object sender, DataReceivedEventArgs e)
{
_logWriter.WriteLine(e.Data);
}
}
}
================================================
FILE: Brenner.SilentCmd/LogWriter.cs
================================================
using System;
using System.Diagnostics;
using System.IO;
namespace Brenner.SilentCmd
{
internal class LogWriter : IDisposable
{
private string _fullPath;
private StreamWriter _writer;
private long _maxSize;
private bool _append;
public bool Initialized { get { return _writer != null; } }
///
/// Initializies a log writer that logs to the specified path.
///
/// Path to the destination log file.
/// True if entrie should be added to an existing log file
public void Initialize(string logPath = null, bool append = false, long maxSize = 0)
{
try
{
if (string.IsNullOrEmpty(logPath)) return; // No logging if no path specified
_fullPath = Environment.ExpandEnvironmentVariables(logPath);
_append = append;
_maxSize = maxSize;
if (_writer != null) _writer.Dispose();
_writer = new StreamWriter(_fullPath, _append);
}
catch (Exception e)
{
Trace.WriteLine(e);
}
}
private void RotateLogFile()
{
try
{
if (_maxSize <= 0) return; // Ignore if no max size specified
if (_writer != null && _writer.BaseStream != null && _writer.BaseStream.Length > _maxSize)
{
_writer.Dispose();
File.Copy(_fullPath, _fullPath + ".old", true);
File.Delete(_fullPath);
_writer = new StreamWriter(_fullPath, _append);
}
}
catch (Exception e)
{
Trace.WriteLine(e);
}
}
public void Dispose()
{
try
{
if (_writer != null)
{
_writer.Dispose();
}
}
catch (Exception e)
{
Trace.WriteLine(e);
}
GC.SuppressFinalize(this);
}
public void WriteLine(string format, params object[] args)
{
try
{
RotateLogFile();
if (_writer != null && format != null)
{
string message = string.Format(format, args);
string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
_writer.WriteLine("{0} - {1}", timestamp, message);
}
}
catch (Exception e)
{
Trace.WriteLine(e);
}
}
}
}
================================================
FILE: Brenner.SilentCmd/Program.cs
================================================
using System;
namespace Brenner.SilentCmd
{
public static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
public static int Main(string[] args)
{
var engine = new Engine();
return engine.Execute(args);
}
}
}
================================================
FILE: Brenner.SilentCmd/Properties/AssemblyInfo.cs
================================================
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SilentCMD")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Stephan Brenner")]
[assembly: AssemblyProduct("SilentCMD")]
[assembly: AssemblyCopyright("Copyright © 2011-2025 Stephan Brenner")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("57e768d9-0964-47e5-ad1c-201a6b296cb2")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
================================================
FILE: Brenner.SilentCmd/Properties/Resources.Designer.cs
================================================
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
namespace Brenner.SilentCmd.Properties {
using System;
///
/// A strongly-typed resource class, for looking up localized strings, etc.
///
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
///
/// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Brenner.SilentCmd.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
///
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
///
/// Looks up a localized string similar to Delaying execution by {0} seconds.
///
internal static string Delay {
get {
return ResourceManager.GetString("Delay", resourceCulture);
}
}
///
/// Looks up a localized string similar to Error: {0}.
///
internal static string Error {
get {
return ResourceManager.GetString("Error", resourceCulture);
}
}
///
/// Looks up a localized string similar to Finished "{0}".
///
internal static string FinishedCommand {
get {
return ResourceManager.GetString("FinishedCommand", resourceCulture);
}
}
///
/// Looks up a localized string similar to SilentCMD.
///
internal static string ProgramTitle {
get {
return ResourceManager.GetString("ProgramTitle", resourceCulture);
}
}
///
/// Looks up a localized string similar to Started "{0}" (PID {1}).
///
internal static string StartingCommand {
get {
return ResourceManager.GetString("StartingCommand", resourceCulture);
}
}
///
/// Looks up a localized string similar to SilentCMD [Options] BatchFile [BatchArguments]
///
///Options:
////? :: Show help
////LOG:file :: Output status to log file (overwrite existing log).
////LOG+:file :: Output status to log file (append to existing log).
////LOGSIZE:bytes :: Maximum log file size after which it is truncated
////DELAY:seconds :: Delay the execution of batch file by x seconds
///
///Examples
///SilentCMD c:\DoSomething.bat
///SilentCMD /LOG:c:\MyLog.txt c:\MyBatch.cmd MyParam1
///SilentCMD /LOG+:c:\MyLog.txt /LOGSIZE:1000000 c:\MyBatch.cmd
///SilentCMD [rest of string was truncated]";.
///
internal static string UserManual {
get {
return ResourceManager.GetString("UserManual", resourceCulture);
}
}
}
}
================================================
FILE: Brenner.SilentCmd/Properties/Resources.resx
================================================
text/microsoft-resx
2.0
System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
SilentCMD [Options] BatchFile [BatchArguments]
Options:
/? :: Show help
/LOG:file :: Output status to log file (overwrite existing log).
/LOG+:file :: Output status to log file (append to existing log).
/LOGSIZE:bytes :: Maximum log file size after which it is truncated
/DELAY:seconds :: Delay the execution of batch file by x seconds
Examples
SilentCMD c:\DoSomething.bat
SilentCMD /LOG:c:\MyLog.txt c:\MyBatch.cmd MyParam1
SilentCMD /LOG+:c:\MyLog.txt /LOGSIZE:1000000 c:\MyBatch.cmd
SilentCMD /DELAY:3600 c:\MyBatch.cmd
Version {0}
Free software under MIT license
More information on https://www.stephan-brenner.com
SilentCMD
Error: {0}
Started "{0}" (PID {1})
Finished "{0}"
Delaying execution by {0} seconds
================================================
FILE: Brenner.SilentCmd/Properties/Settings.Designer.cs
================================================
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
namespace Brenner.SilentCmd.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string DefaultBatchFilePath {
get {
return ((string)(this["DefaultBatchFilePath"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string DefaultBatchFileArguments {
get {
return ((string)(this["DefaultBatchFileArguments"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("%temp%\\SilentCMD.log")]
public string DefaultLogFilePath {
get {
return ((string)(this["DefaultLogFilePath"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool DefaultLogAppend {
get {
return ((bool)(this["DefaultLogAppend"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("00:00:00")]
public global::System.TimeSpan DefaultDelay {
get {
return ((global::System.TimeSpan)(this["DefaultDelay"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public long DefaultLogSize {
get {
return ((long)(this["DefaultLogSize"]));
}
}
}
}
================================================
FILE: Brenner.SilentCmd/Properties/Settings.settings
================================================
%temp%\SilentCMD.log
False
00:00:00
0
================================================
FILE: Brenner.SilentCmd/app.config
================================================
%temp%\SilentCMD.log
False
00:00:00
0
================================================
FILE: Brenner.SilentCmd.Tests/Brenner.SilentCmd.Tests.csproj
================================================
Debug
AnyCPU
{A2A99298-3567-4D16-8FEF-1FD0DACA3178}
Library
Properties
Brenner.SilentCmd.Tests
Brenner.SilentCmd.Tests
v4.8
512
true
true
full
false
bin\Debug\
DEBUG;TRACE
prompt
4
pdbonly
true
bin\Release\
TRACE
prompt
4
..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll
..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll
..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll
..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll
{461e6475-6450-40ed-b68c-7f012701e6c6}
Brenner.SilentCmd
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
================================================
FILE: Brenner.SilentCmd.Tests/ConfigurationTest.cs
================================================
using System;
using Xunit;
namespace Brenner.SilentCmd.Tests
{
public class ConfigurationTest
{
[Fact]
public void Log()
{
Configuration config = new Configuration();
config.ParseArguments(new string[] {@"/LOG:c:\temp\test.log"});
Assert.False(config.LogAppend);
Assert.Equal(@"c:\temp\test.log", config.LogFilePath);
}
[Fact]
public void NotLog()
{
Configuration config = new Configuration();
config.ParseArguments(new string[] { @"/LOGA:c:\temp\test.log" });
Assert.Null(config.LogFilePath);
}
[Fact]
public void LogPlus()
{
Configuration config = new Configuration();
config.ParseArguments(new string[] { "/LOG+:\"c:\\My Files\\test.log\"" });
Assert.True(config.LogAppend);
Assert.Equal(@"c:\My Files\test.log", config.LogFilePath);
}
[Fact]
public void Delay()
{
Configuration config = new Configuration();
config.ParseArguments(new string[] { "/DELAY:1234" });
Assert.Equal(TimeSpan.FromSeconds(1234), config.Delay);
}
[Fact]
public void Help()
{
Configuration config = new Configuration();
config.ParseArguments(new string[] { "/?" });
Assert.True(config.ShowHelp);
}
}
}
================================================
FILE: Brenner.SilentCmd.Tests/Dummy.cmd
================================================
@echo off
echo This is a test batch file for SilentCMD
echo Parameter 1: %1
echo Date: %date%
TIMEOUT /T 5
exit /B 1234
================================================
FILE: Brenner.SilentCmd.Tests/Properties/AssemblyInfo.cs
================================================
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Brenner.SilentCmd.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Avira Operations GmbH & Co. KG;")]
[assembly: AssemblyProduct("Brenner.SilentCmd.Tests")]
[assembly: AssemblyCopyright("Copyright © Avira Operations GmbH & Co. KG; 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a2a99298-3567-4d16-8fef-1fd0daca3178")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
================================================
FILE: Brenner.SilentCmd.Tests/TestDelay.cmd
================================================
@echo off
"%~dp0\..\Brenner.SilentCmd\bin\Debug\SilentCMD.exe" "%~dp0\Dummy.cmd" param /LOG:"%temp%\TestDelay.log" /DELAY:5
================================================
FILE: Brenner.SilentCmd.Tests/packages.config
================================================
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2011 Stephan Brenner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# SilentCMD
SilentCMD executes a batch file without opening the command prompt window. If required, the console output can be redirected to a log file.
### Command Line Syntax
```
SilentCMD [Options] BatchFile [BatchArguments]
Options:
/? :: Show help
/LOG:file :: Output status to LOG file (overwrite existing log)
/LOG+:file :: Output status to LOG file (append to existing log)
/LOGSIZE:bytes :: Maximum log file size after which it is truncated
/DELAY:seconds :: Delay the execution of batch file by x seconds
```
#### Examples
```
SilentCMD c:\DoSomething.bat
SilentCMD /LOG:c:\MyLog.txt c:\MyBatch.cmd MyParam1
SilentCMD /LOG+:c:\MyLog.txt /LOGSIZE:1000000 c:\MyBatch.cmd
SilentCMD /DELAY:3600 c:\MyBatch.cmd
```
### Use Cases
You can use SilentCMD for running batch files from the Windows Task Scheduler. With the tool you do not get interrupted by the command prompt window that normally would pop up.
You can call SilentCMD without parameters if required (e.g. when double-clicking it in Windows Explorer). In that case you have to specify the default parameters in SilentCMD.exe.config.
```
c:\temp\test.cmd
arg1 arg2=xyz
```
================================================
FILE: SilentCmd.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Brenner.SilentCmd", "Brenner.SilentCmd\Brenner.SilentCmd.csproj", "{461E6475-6450-40ED-B68C-7F012701E6C6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Brenner.SilentCmd.Tests", "Brenner.SilentCmd.Tests\Brenner.SilentCmd.Tests.csproj", "{A2A99298-3567-4D16-8FEF-1FD0DACA3178}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{461E6475-6450-40ED-B68C-7F012701E6C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{461E6475-6450-40ED-B68C-7F012701E6C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{461E6475-6450-40ED-B68C-7F012701E6C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{461E6475-6450-40ED-B68C-7F012701E6C6}.Release|Any CPU.Build.0 = Release|Any CPU
{A2A99298-3567-4D16-8FEF-1FD0DACA3178}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2A99298-3567-4D16-8FEF-1FD0DACA3178}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2A99298-3567-4D16-8FEF-1FD0DACA3178}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2A99298-3567-4D16-8FEF-1FD0DACA3178}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6AE95268-5757-4AF5-B1FB-50DB017CF1DA}
EndGlobalSection
EndGlobal