Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
MAJ 1.8.2 :
Browse files Browse the repository at this point in the history
- correction régression d'enregistrement de la tâche planifiée
- documentation
  • Loading branch information
geeooff committed Jan 31, 2017
1 parent 595d380 commit ea4ec04
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 50 deletions.
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
85 changes: 46 additions & 39 deletions Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public class Installer : System.Configuration.Install.Installer

public override void Install(IDictionary stateSaver)
{
#if DEBUG
if (!Debugger.IsAttached)
{
Debugger.Launch();
}
Debugger.Break();
#endif

base.Install(stateSaver);

previousEnableEventLog = InstallerConfig.EnableEventLog;
Expand Down Expand Up @@ -70,6 +78,14 @@ public override void Rollback(IDictionary savedState)

public override void Uninstall(IDictionary savedState)
{
#if DEBUG
if (!Debugger.IsAttached)
{
Debugger.Launch();
}
Debugger.Break();
#endif

base.Uninstall(savedState);

try
Expand Down Expand Up @@ -112,50 +128,41 @@ private void InstallTask(IDictionary stateSaver)
// init. task scheduler service engine
using (TS.TaskService ts = new TS.TaskService())
{
// check if scheduler engine is V2 (starting with
// check if scheduler engine is V2
isNewGen = (ts.HighestSupportedVersion >= new Version(1, 2));

TS.TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = DefaultTaskDescription;

try
{
td.RegistrationInfo.Description = DefaultTaskDescription;

td.Actions.Add(
new TS.ExecAction(targetExeFileInfo.FullName)
);

// triggers every day, one hour after midnight UTC
TS.DailyTrigger trigger = new TS.DailyTrigger();
trigger.StartBoundary = new DateTime(1982, 4, 15, 1, 0, 0, DateTimeKind.Utc);
td.Triggers.Add(trigger);

if (isNewGen)
{
td.Settings.Priority = ProcessPriorityClass.BelowNormal;
}

td.Settings.ExecutionTimeLimit = TimeSpan.FromDays(1d);
td.Settings.DisallowStartIfOnBatteries = false;
td.Settings.StopIfGoingOnBatteries = false;

// the task needs to be explicitly enabled by user
td.Settings.Enabled = false;

TS.Task task = ts.RootFolder.RegisterTaskDefinition(
DefaultTaskName,
td,
TS.TaskCreation.CreateOrUpdate,
isNewGen ? "S-1-5-18" : null,
LogonType: TS.TaskLogonType.ServiceAccount
);
taskName = task.Name;
}
finally
td.Actions.Add(
new TS.ExecAction(targetExeFileInfo.FullName)
);

// triggers every day, one hour after midnight UTC
TS.DailyTrigger trigger = new TS.DailyTrigger();
trigger.StartBoundary = new DateTime(1982, 4, 15, 1, 0, 0, DateTimeKind.Utc);
td.Triggers.Add(trigger);

if (isNewGen)
{
// TS.TaskDefinition have .Dispose() method but isn't IDisposable o_O
td.Dispose();
td.Settings.Priority = ProcessPriorityClass.BelowNormal;
}

td.Settings.ExecutionTimeLimit = TimeSpan.FromDays(1d);
td.Settings.DisallowStartIfOnBatteries = false;
td.Settings.StopIfGoingOnBatteries = false;

// the task needs to be explicitly enabled by user
td.Settings.Enabled = false;

TS.Task task = ts.RootFolder.RegisterTaskDefinition(
DefaultTaskName,
td,
TS.TaskCreation.CreateOrUpdate,
isNewGen ? "SYSTEM" : null,
LogonType: TS.TaskLogonType.ServiceAccount
);
taskName = task.Name;
}

// remembers the registered task name for future uninstall
Expand All @@ -166,7 +173,7 @@ private void InstallTask(IDictionary stateSaver)
this.Context.LogMessage("Information: The scheduled task is DISABLED by default !");

// TODO don't advise to use schtasks.exe for older windows (which older ones ?)
this.Context.LogMessage("Information: Execute this command line to enable: schtasks.exe /Change /TN \"" + taskName + "\" /ENABLE");
this.Context.LogMessage("Information: Execute this command line to enable: SCHTASKS /Change /TN \"" + taskName + "\" /ENABLE");
}

private void UninstallTask(IDictionary savedState)
Expand Down
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
[assembly: AssemblyConfiguration("Release")]
#endif

[assembly: AssemblyVersion("1.8.1.0")]
[assembly: AssemblyFileVersion("1.8.1.0")]
[assembly: AssemblyInformationalVersion("1.8.1")]
[assembly: AssemblyVersion("1.8.2.0")]
[assembly: AssemblyFileVersion("1.8.2.0")]
[assembly: AssemblyInformationalVersion("1.8.2")]
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# IIS Log Rotator
Microsoft Internet Information Services Log Rotation program.

---

## Features

1. Autodetects installed IIS services and file logging settings
Expand Down Expand Up @@ -38,8 +36,6 @@ Web Management Service (WMSvc) logs are __not yet__ supported.
* Windows Server 2008 / Vista only: IIS 6 Metabase Compatibility feature
* Administrator rights (because of WMI and IIS Metabase readings)

---

## How to run

1. Extract the program to a local folder
Expand All @@ -52,15 +48,14 @@ If you need to execute the program daily and have reports to Windows Event Log,
you should register it to Windows Task Scheduler.

1. Execute `install.cmd` with Administrator rights
2. Modify scheduled task named `IIS Logs Rotation` if not satisfied with default settings (every day at 1:00 am UTC)
2. Modify scheduled task named `IIS Logs Rotation` manually if not satisfied with default settings (every day at 1:00 am UTC)
3. Enable scheduled task named `IIS Logs Rotation` manually, or execute `SCHTASKS /Change /TN "IIS Logs Rotation" /ENABLE`

## How to uninstall / unschedule

* To remove everything, execute `uninstall.cmd` with Administrator rights
* To disable the scheduled task, disable Windows scheduled task named `IIS Logs Rotation`, or execute `SCHTASKS /Change /TN "IIS Logs Rotation" /DISABLE`

---

## Settings

Open the `IisLogRotator.config` file with an XML-aware editor (like [Visual Studio Code](http://code.visualstudio.com), [Sublime Text](http://www.sublimetext.com)) to avoid errors.
Expand Down Expand Up @@ -93,7 +88,16 @@ Example for `W3SVC1` Website settings, to do deletion only after 30 days :
</rotation>
```

### `defaultSettings` / `siteSettings` allowed values
### `rotation` element allowed attribute values

| Attribute | Values |
| --- | --- |
| `enableEventLog` | `true` to enable Windows event log reports or `false` (default) to disable |

Windows event logs reports are enabled when the program is installed using `install.cmd` and should not be enabled without,
or Windows will complain about missing event log source identifier.

### `defaultSettings` / `siteSettings` elements allowed attribute values

| Attribute | Values |
| --- | --- |
Expand Down

0 comments on commit ea4ec04

Please sign in to comment.