Skip to content

Commit 7ebe830

Browse files
Removed CMD CLI added FodyWeavers for NDesk.Options dll.
Added -h -r -y -p -d options for running from CMD Output for -h hangs and requires user to press enter
1 parent 6ab9896 commit 7ebe830

7 files changed

Lines changed: 214 additions & 82 deletions

File tree

AutoLoginBuilder/AutoLoginBuilder.csproj

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\Costura.Fody.3.3.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.3.0\build\Costura.Fody.props')" />
34
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
45
<PropertyGroup>
56
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -11,6 +12,8 @@
1112
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1213
<FileAlignment>512</FileAlignment>
1314
<TargetFrameworkProfile />
15+
<NuGetPackageImportStamp>
16+
</NuGetPackageImportStamp>
1417
</PropertyGroup>
1518
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1619
<PlatformTarget>x64</PlatformTarget>
@@ -49,12 +52,14 @@
4952
<ApplicationIcon>ninjakirby_71d_icon.ico</ApplicationIcon>
5053
</PropertyGroup>
5154
<ItemGroup>
55+
<Reference Include="Costura, Version=3.3.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
56+
<HintPath>..\packages\Costura.Fody.3.3.0\lib\net40\Costura.dll</HintPath>
57+
</Reference>
58+
<Reference Include="NDesk.Options, Version=0.2.1.0, Culture=neutral, processorArchitecture=MSIL">
59+
<HintPath>..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll</HintPath>
60+
</Reference>
5261
<Reference Include="System" />
5362
<Reference Include="System.Core" />
54-
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
55-
<SpecificVersion>False</SpecificVersion>
56-
<HintPath>..\..\..\..\..\..\..\Windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll</HintPath>
57-
</Reference>
5863
<Reference Include="System.Xml.Linq" />
5964
<Reference Include="System.Data.DataSetExtensions" />
6065
<Reference Include="System.Data" />
@@ -64,7 +69,6 @@
6469
<Reference Include="System.Xml" />
6570
</ItemGroup>
6671
<ItemGroup>
67-
<Compile Include="Lib\CMDCli.cs" />
6872
<Compile Include="Form1.cs">
6973
<SubType>Form</SubType>
7074
</Compile>
@@ -91,6 +95,7 @@
9195
<None Include="app.manifest">
9296
<SubType>Designer</SubType>
9397
</None>
98+
<None Include="packages.config" />
9499
<None Include="Properties\Settings.settings">
95100
<Generator>SettingsSingleFileGenerator</Generator>
96101
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -102,7 +107,16 @@
102107
</Compile>
103108
</ItemGroup>
104109
<ItemGroup>
110+
<Content Include="FodyWeavers.xml" />
105111
<Content Include="ninjakirby_71d_icon.ico" />
106112
</ItemGroup>
107113
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
114+
<Import Project="..\packages\Fody.3.3.5\build\Fody.targets" Condition="Exists('..\packages\Fody.3.3.5\build\Fody.targets')" />
115+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
116+
<PropertyGroup>
117+
<ErrorText>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}.</ErrorText>
118+
</PropertyGroup>
119+
<Error Condition="!Exists('..\packages\Fody.3.3.5\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.3.5\build\Fody.targets'))" />
120+
<Error Condition="!Exists('..\packages\Costura.Fody.3.3.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.3.0\build\Costura.Fody.props'))" />
121+
</Target>
108122
</Project>

AutoLoginBuilder/FodyWeavers.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
3+
<Costura />
4+
</Weavers>

AutoLoginBuilder/FodyWeavers.xsd

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3+
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
4+
<xs:element name="Weavers">
5+
<xs:complexType>
6+
<xs:all>
7+
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
8+
<xs:complexType>
9+
<xs:all>
10+
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
11+
<xs:annotation>
12+
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
13+
</xs:annotation>
14+
</xs:element>
15+
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
16+
<xs:annotation>
17+
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
18+
</xs:annotation>
19+
</xs:element>
20+
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
21+
<xs:annotation>
22+
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
23+
</xs:annotation>
24+
</xs:element>
25+
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
26+
<xs:annotation>
27+
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
28+
</xs:annotation>
29+
</xs:element>
30+
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
31+
<xs:annotation>
32+
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
33+
</xs:annotation>
34+
</xs:element>
35+
</xs:all>
36+
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
37+
<xs:annotation>
38+
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
39+
</xs:annotation>
40+
</xs:attribute>
41+
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
42+
<xs:annotation>
43+
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
44+
</xs:annotation>
45+
</xs:attribute>
46+
<xs:attribute name="DisableCompression" type="xs:boolean">
47+
<xs:annotation>
48+
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
49+
</xs:annotation>
50+
</xs:attribute>
51+
<xs:attribute name="DisableCleanup" type="xs:boolean">
52+
<xs:annotation>
53+
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
54+
</xs:annotation>
55+
</xs:attribute>
56+
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
57+
<xs:annotation>
58+
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
59+
</xs:annotation>
60+
</xs:attribute>
61+
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
62+
<xs:annotation>
63+
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
64+
</xs:annotation>
65+
</xs:attribute>
66+
<xs:attribute name="ExcludeAssemblies" type="xs:string">
67+
<xs:annotation>
68+
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
69+
</xs:annotation>
70+
</xs:attribute>
71+
<xs:attribute name="IncludeAssemblies" type="xs:string">
72+
<xs:annotation>
73+
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
74+
</xs:annotation>
75+
</xs:attribute>
76+
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
77+
<xs:annotation>
78+
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
79+
</xs:annotation>
80+
</xs:attribute>
81+
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
82+
<xs:annotation>
83+
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
84+
</xs:annotation>
85+
</xs:attribute>
86+
<xs:attribute name="PreloadOrder" type="xs:string">
87+
<xs:annotation>
88+
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
89+
</xs:annotation>
90+
</xs:attribute>
91+
</xs:complexType>
92+
</xs:element>
93+
</xs:all>
94+
<xs:attribute name="VerifyAssembly" type="xs:boolean">
95+
<xs:annotation>
96+
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
97+
</xs:annotation>
98+
</xs:attribute>
99+
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
100+
<xs:annotation>
101+
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
102+
</xs:annotation>
103+
</xs:attribute>
104+
<xs:attribute name="GenerateXsd" type="xs:boolean">
105+
<xs:annotation>
106+
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
107+
</xs:annotation>
108+
</xs:attribute>
109+
</xs:complexType>
110+
</xs:element>
111+
</xs:schema>

AutoLoginBuilder/Lib/CMDCli.cs

Lines changed: 0 additions & 51 deletions
This file was deleted.

AutoLoginBuilder/Lib/Worker.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@ public int autoLoginCommand(string username = null, string password = null, stri
3434
key.Close();
3535
}
3636
}
37-
else if(username != null && password != null)
38-
{
39-
if (key != null)
40-
{
41-
key.SetValue("AutoAdminLogon", "1", RegistryValueKind.String);
42-
key.SetValue("DefaultUserName", username, RegistryValueKind.String);
43-
key.SetValue("DefaultDomainName", "", RegistryValueKind.String);
44-
key.SetValue("DefaultPassword", password, RegistryValueKind.String);
45-
key.Close();
46-
}
47-
}
4837
else
4938
{
5039
if (key != null)

AutoLoginBuilder/Program.cs

Lines changed: 74 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
using System;
2+
using System.Collections.Generic;
3+
using System.Runtime.InteropServices;
24
using System.Windows.Forms;
5+
using NDesk.Options;
36

47
namespace AutoLoginBuilder
58
{
69
static class Program
710
{
811

12+
//Setup for Redirect to MS Console
13+
[DllImport("kernel32.dll")]
14+
static extern bool AttachConsole(int dwProcessId);
15+
private const int ATTACH_PARENT_PROCESS = -1;
16+
17+
918
/// <summary>
1019
/// The main entry point for the application.
1120
/// </summary>
@@ -20,25 +29,75 @@ static void Main(string[] args)
2029
}
2130
else
2231
{
23-
CMDCli cmd = new CMDCli();
24-
if (args[0] == @"/?")
25-
{
26-
MessageBox.Show(
27-
"CMD : Results" + "\n" +
28-
"==============================================" + "\n" +
29-
"==============================================" + "\n" +
30-
"AutoLoginBuilder.exe remove : WILL REMOVE AUTOLOGIN" + "\n" +
31-
"AutoLoginBuilder.exe USERNAME PASSWORD : Will add Auto Login for local users" + "\n" +
32-
"AutoLoginBuilder.exe DOMAIN USERNAME PASSWORD : Will add Auto Login for Domain Users" + "\n" +
33-
"==============================================" + "\n" +
34-
"==============================================");
35-
}
32+
bool show_help = false;
33+
bool remove = false;
3634

37-
else
35+
string username = null;
36+
string password = null;
37+
string domain = "";
38+
Worker wkr = new Worker();
39+
40+
var p = new OptionSet()
41+
{
42+
{
43+
"h|help", "Shows help msg and exits",
44+
v => show_help = v != null
45+
},
46+
{
47+
"r|remove", "Removes Auto Login",
48+
v => remove = v != null
49+
},
50+
{
51+
"u|username=", "Computer Account being set for Auto Login",
52+
v => username = v
53+
},
54+
{
55+
"p|password=", "Password for account being set for Auto Login",
56+
v => password = v
57+
},
58+
{
59+
"d|domain=", "Domain for account being set for Auto Login.\n"+
60+
"Leave Blank for local account",
61+
v => domain = v
62+
},
63+
64+
};
65+
List<string> extra;
66+
try
3867
{
39-
cmd.arguments(args);
68+
extra = p.Parse(args);
69+
}
70+
catch (OptionException e)
71+
{
72+
Console.WriteLine(e.Message);
73+
}
74+
if (show_help)
75+
{
76+
//Redirect to MS Console
77+
AttachConsole(ATTACH_PARENT_PROCESS);
78+
Console.WriteLine();
79+
ShowHelp(p);
80+
Environment.Exit(0);
81+
}
82+
else if (remove)
83+
{
84+
int success = wkr.autoLoginCommand();
85+
}
86+
else if (username != null && password != null)
87+
{
88+
int success = wkr.autoLoginCommand(username, password, domain);
4089
}
4190
}
4291
}
92+
static void ShowHelp(OptionSet p)
93+
{
94+
Console.WriteLine("-----------------------------------------------------");
95+
Console.WriteLine(" Welcome to the help for this auto Login");
96+
Console.WriteLine(" Remember domain can be blank for localhost");
97+
Console.WriteLine();
98+
Console.WriteLine("Options:");
99+
p.WriteOptionDescriptions(Console.Out);
100+
Environment.Exit(0);
101+
}
43102
}
44103
}

AutoLoginBuilder/packages.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Costura.Fody" version="3.3.0" targetFramework="net45" />
4+
<package id="Fody" version="3.3.5" targetFramework="net45" developmentDependency="true" />
5+
<package id="NDesk.Options" version="0.2.1" targetFramework="net45" />
6+
</packages>

0 commit comments

Comments
 (0)