Skip to content

Commit 69ee0ab

Browse files
committed
Added a helper utility to launch MenuTools.exe via a scheduled task.
(issue #1)
1 parent 64a1fa6 commit 69ee0ab

File tree

9 files changed

+237
-2
lines changed

9 files changed

+237
-2
lines changed

MenuTools.sln

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.30501.0
4+
VisualStudioVersion = 12.0.40629.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MenuTools", "MenuTools\MenuTools.vcxproj", "{B2AB229B-B08C-4D3E-9EFE-CDF6B44DFA09}"
77
ProjectSection(ProjectDependencies) = postProject
@@ -15,6 +15,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MenuToolsHook", "MenuToolsH
1515
EndProject
1616
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MenuCommon", "MenuCommon\MenuCommon.vcxproj", "{44E96425-5FCD-42D4-8BB6-9D15FBEE6912}"
1717
EndProject
18+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "helper", "helper\helper.vcxproj", "{E874E65E-B2BA-4C49-A5EE-8220C7DE6009}"
19+
EndProject
1820
Global
1921
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2022
Debug|Win32 = Debug|Win32
@@ -47,6 +49,12 @@ Global
4749
{44E96425-5FCD-42D4-8BB6-9D15FBEE6912}.Release|Win32.Build.0 = Release|Win32
4850
{44E96425-5FCD-42D4-8BB6-9D15FBEE6912}.Release|x64.ActiveCfg = Release|x64
4951
{44E96425-5FCD-42D4-8BB6-9D15FBEE6912}.Release|x64.Build.0 = Release|x64
52+
{E874E65E-B2BA-4C49-A5EE-8220C7DE6009}.Debug|Win32.ActiveCfg = Debug|Win32
53+
{E874E65E-B2BA-4C49-A5EE-8220C7DE6009}.Debug|Win32.Build.0 = Debug|Win32
54+
{E874E65E-B2BA-4C49-A5EE-8220C7DE6009}.Debug|x64.ActiveCfg = Debug|Win32
55+
{E874E65E-B2BA-4C49-A5EE-8220C7DE6009}.Release|Win32.ActiveCfg = Release|Win32
56+
{E874E65E-B2BA-4C49-A5EE-8220C7DE6009}.Release|Win32.Build.0 = Release|Win32
57+
{E874E65E-B2BA-4C49-A5EE-8220C7DE6009}.Release|x64.ActiveCfg = Release|Win32
5058
EndGlobalSection
5159
GlobalSection(SolutionProperties) = preSolution
5260
HideSolutionNode = FALSE

MenuTools/MenuTools.rc

0 Bytes
Binary file not shown.

Setup/setup.iss

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
#define CODESIGN FALSE
55

66
#define MyAppName "MenuTools"
7-
#define MyAppVersion "1.0.1"
7+
#define MyAppVersion "1.0.2"
88
#define MyAppPublisher "Rafael Cossovan de França"
99
#define MyAppURL "http://www.navossoc.com/menutools/"
1010
#define MyAppExeName "MenuTools.exe"
1111
#define MyAppWindowClass "MENUTOOLS"
12+
#define MyHelperExeName "helper.exe"
1213

1314
[Setup]
1415
; NOTE: The value of AppId uniquely identifies this application.
@@ -57,6 +58,7 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
5758
Name: "startupicon"; Description: "{cm:AutoStartProgram,{#MyAppName}}"; GroupDescription: "{cm:AutoStartProgramGroupDescription}"
5859

5960
[Files]
61+
Source: "Release\{#MyHelperExeName}"; DestDir: "{app}"; Flags: ignoreversion uninsrestartdelete;
6062
Source: "Release\MenuTools.exe"; DestDir: "{app}"; Flags: ignoreversion uninsrestartdelete;
6163
Source: "Release\MenuTools64.exe"; DestDir: "{app}"; Flags: ignoreversion uninsrestartdelete; Check: Is64BitInstallMode
6264
Source: "Release\MenuToolsHook.dll"; DestDir: "{app}"; Flags: ignoreversion uninsrestartdelete
@@ -73,6 +75,12 @@ Name: "{commonstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks:
7375

7476
[Run]
7577
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall runascurrentuser skipifsilent
78+
Filename: "schtasks"; \
79+
Parameters: "/Create /SC ONLOGON /TN ""{#MyAppName}"" /TR ""'{app}\{#MyHelperExeName}'"" /RL HIGHEST /F"; \
80+
Flags: runhidden; Tasks: startupicon
81+
82+
[UninstallRun]
83+
Filename: "schtasks"; Parameters: "/Delete /TN ""{#MyAppName}"" /F"; Flags: runhidden
7684

7785
[Code]
7886
function InitializeUninstall(): Boolean;

helper/helper.cpp

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// helper.cpp : Defines the entry point for the application.
2+
//
3+
4+
#include "stdafx.h"
5+
6+
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
7+
_In_opt_ HINSTANCE hPrevInstance,
8+
_In_ LPWSTR lpCmdLine,
9+
_In_ int nCmdShow)
10+
{
11+
UNREFERENCED_PARAMETER(hPrevInstance);
12+
13+
// Infers the current directory from fully qualified path, since the
14+
// working directory was not defined by the task created by schtasks.
15+
LPWSTR *szArglist;
16+
int nArgs;
17+
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
18+
if (szArglist == NULL)
19+
{
20+
return 1;
21+
}
22+
23+
WCHAR drive[_MAX_DRIVE];
24+
WCHAR dir[_MAX_DIR];
25+
if (_wsplitpath_s(szArglist[0], drive, _MAX_DRIVE, dir, _MAX_DIR, NULL, 0, NULL, 0) != 0)
26+
{
27+
LocalFree(szArglist);
28+
return 1;
29+
}
30+
31+
LocalFree(szArglist);
32+
33+
WCHAR lpDirectory[MAX_PATH];
34+
_wmakepath_s(lpDirectory, drive, dir, NULL, NULL);
35+
36+
// Execute process
37+
SHELLEXECUTEINFOW ShExecInfo;
38+
39+
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
40+
ShExecInfo.fMask = SEE_MASK_NOASYNC;
41+
ShExecInfo.hwnd = NULL;
42+
ShExecInfo.lpVerb = L"open";
43+
ShExecInfo.lpFile = L"MenuTools.exe";
44+
ShExecInfo.lpParameters = lpCmdLine;
45+
ShExecInfo.lpDirectory = lpDirectory;
46+
ShExecInfo.nShow = SW_HIDE;
47+
ShExecInfo.hInstApp = NULL;
48+
49+
if (ShellExecuteExW(&ShExecInfo) == FALSE)
50+
{
51+
return GetLastError();
52+
}
53+
54+
return 0;
55+
}

helper/helper.vcxproj

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<ProjectGuid>{E874E65E-B2BA-4C49-A5EE-8220C7DE6009}</ProjectGuid>
15+
<Keyword>Win32Proj</Keyword>
16+
<RootNamespace>helper</RootNamespace>
17+
</PropertyGroup>
18+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
19+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
20+
<ConfigurationType>Application</ConfigurationType>
21+
<UseDebugLibraries>true</UseDebugLibraries>
22+
<PlatformToolset>v120_xp</PlatformToolset>
23+
<CharacterSet>Unicode</CharacterSet>
24+
</PropertyGroup>
25+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
26+
<ConfigurationType>Application</ConfigurationType>
27+
<UseDebugLibraries>false</UseDebugLibraries>
28+
<PlatformToolset>v120_xp</PlatformToolset>
29+
<WholeProgramOptimization>true</WholeProgramOptimization>
30+
<CharacterSet>Unicode</CharacterSet>
31+
</PropertyGroup>
32+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
33+
<ImportGroup Label="ExtensionSettings">
34+
</ImportGroup>
35+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
36+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
37+
</ImportGroup>
38+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
39+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
40+
</ImportGroup>
41+
<PropertyGroup Label="UserMacros" />
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
43+
<LinkIncremental>true</LinkIncremental>
44+
</PropertyGroup>
45+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
46+
<LinkIncremental>false</LinkIncremental>
47+
</PropertyGroup>
48+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
49+
<ClCompile>
50+
<PrecompiledHeader>Use</PrecompiledHeader>
51+
<WarningLevel>Level3</WarningLevel>
52+
<Optimization>Disabled</Optimization>
53+
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
54+
<SDLCheck>true</SDLCheck>
55+
</ClCompile>
56+
<Link>
57+
<SubSystem>Windows</SubSystem>
58+
<GenerateDebugInformation>true</GenerateDebugInformation>
59+
</Link>
60+
</ItemDefinitionGroup>
61+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
62+
<ClCompile>
63+
<WarningLevel>Level3</WarningLevel>
64+
<PrecompiledHeader>Use</PrecompiledHeader>
65+
<Optimization>MaxSpeed</Optimization>
66+
<FunctionLevelLinking>true</FunctionLevelLinking>
67+
<IntrinsicFunctions>true</IntrinsicFunctions>
68+
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
69+
<SDLCheck>true</SDLCheck>
70+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
71+
</ClCompile>
72+
<Link>
73+
<SubSystem>Windows</SubSystem>
74+
<GenerateDebugInformation>true</GenerateDebugInformation>
75+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
76+
<OptimizeReferences>true</OptimizeReferences>
77+
</Link>
78+
</ItemDefinitionGroup>
79+
<ItemGroup>
80+
<ClInclude Include="stdafx.h" />
81+
<ClInclude Include="targetver.h" />
82+
</ItemGroup>
83+
<ItemGroup>
84+
<ClCompile Include="helper.cpp" />
85+
<ClCompile Include="stdafx.cpp">
86+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
87+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
88+
</ClCompile>
89+
</ItemGroup>
90+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
91+
<ImportGroup Label="ExtensionTargets">
92+
</ImportGroup>
93+
</Project>

helper/helper.vcxproj.filters

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClInclude Include="stdafx.h">
19+
<Filter>Header Files</Filter>
20+
</ClInclude>
21+
<ClInclude Include="targetver.h">
22+
<Filter>Header Files</Filter>
23+
</ClInclude>
24+
</ItemGroup>
25+
<ItemGroup>
26+
<ClCompile Include="stdafx.cpp">
27+
<Filter>Source Files</Filter>
28+
</ClCompile>
29+
<ClCompile Include="helper.cpp">
30+
<Filter>Source Files</Filter>
31+
</ClCompile>
32+
</ItemGroup>
33+
</Project>

helper/stdafx.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// stdafx.cpp : source file that includes just the standard includes
2+
// helper.pch will be the pre-compiled header
3+
// stdafx.obj will contain the pre-compiled type information
4+
5+
#include "stdafx.h"
6+
7+
// TODO: reference any additional headers you need in STDAFX.H
8+
// and not in this file

helper/stdafx.h

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// stdafx.h : include file for standard system include files,
2+
// or project specific include files that are used frequently, but
3+
// are changed infrequently
4+
//
5+
6+
#pragma once
7+
8+
#include "targetver.h"
9+
10+
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
11+
// Windows Header Files:
12+
#include <windows.h>
13+
14+
// C RunTime Header Files
15+
#include <stdlib.h>
16+
#include <malloc.h>
17+
#include <memory.h>
18+
19+
20+
// TODO: reference additional headers your program requires here
21+
#include <shellapi.h>
22+
#include <stdlib.h>

helper/targetver.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
// Including SDKDDKVer.h defines the highest available Windows platform.
4+
5+
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6+
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7+
8+
#include <SDKDDKVer.h>

0 commit comments

Comments
 (0)