Wednesday, January 18, 2017

Dynamic web interface in cplusplus CPP visual studio 2013



2017-03-08
For visual studio 2017 community
1.
bug: #include "stdio.h"
Go in setup ("C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe")
In second tab, add MFC support
Change include folders path in project:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\ucrt;C:\Program Files %28x86%29\Windows Kits\10\Lib\10.0.14393.0\ucrt\x86;$(IncludePath)

2.
Download and install the windows 10 sdk
https://dev.windows.com/en-US/downloads/windows-10-sdk

3.
ucrtd.lib bug
libraries include path:
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\ucrt\x86


2017-01-22
Configured to compile as Release
(check comment in code: Troubleshooting)
added include "windows.h" for innerhtml to work


2017-12-20
Events stopped working :(
After a reboot, it worked again
So maybe i need to free some event before closing internet explorer

2017-12-19
Corected management of left menu to exit any input form
Passed the vector as pointers, not global variables anymore

-----

This is CPP using internet explorer as an interface

Tested in windows 10

Requis:
Visual studio 2013

Warning:
not optimized at all, no release of variables (i will add later)


// ConsoleApplication1.cpp

// visual studio 2013 cpp console application

// Troubleshooting:
/* Project  "project" Properties->Configuration Properties->C / C++->Advanced->Show Includes : YES(/ showIncludes) */
// Project  "project" Properties->Configuration Properties->General->Project Defaults->Use of MFC : Use MFC in a shared DLL

// #undef True
// #undef False

#include "stdafx.h"
#include "stdio.h"
#include "afx.h"
#include <string>
#include <malloc.h>
#include <iostream>
#include <vector>
#include "Windows.h"

#include "Exdisp.h"
#import "shdocvw.dll"
#include <MsHTML.h>
#include <afxdisp.h>

#include <cassert>


//#define _AFXDLL C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afx.h
//C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afx.h 24 1 ConsoleApplication1


using std::cout;
using std::wcout;

bool WaitTillLoaded(int nTimeout);
int writeln01(IHTMLDocument2* phtmldoc1, std::wstring string01);
int create_web_main(
std::vector<std::wstring>* arrbutnam,
std::vector<std::wstring>* arrbutdes,
std::vector<std::wstring>* arrdepnam,
std::vector<std::wstring>* arrdepcol);
// name of button on left frame (also ID)
// description or caption
// sector (sectors have a space between them)
// button color of a sector

IHTMLDocument2* gethtmele(IHTMLDocument2* phtmldoc2, std::wstring frame01);
void doevents();
std::string getdefaultbrowserpath();
void clrfra(IHTMLDocument2* fra);

HWND m_hWnd; // handle for this console application
IWebBrowser2* pbrowser; // internet explorer object
IHTMLDocument2* flef; // frame left document html
IHTMLDocument2* fmid;
IHTMLDocument2* fbot;
IHTMLDocument2* pHtmlDoc; // main itnernet explorer windows html content
bool iexploreclosed = FALSE; // internet explorer still exist (was not closed), an event will manage this in the futur
IHTMLElement* findhtmlelement(IHTMLDocument2* fra, std::wstring type01, std::wstring name01);

std::vector<std::wstring>  dynforgen(IHTMLDocument2 *fra, std::wstring *title01,
std::vector<std::wstring>* destmp,
std::vector<std::wstring>* namtmp,
std::vector<std::wstring>* deftmp,
std::vector<std::wstring>* typtmp,
std::vector<std::wstring>* errtmp,
std::vector<std::wstring>* buttmp);

std::wstring resbutlef;
std::wstring resbutmid;
std::wstring resbutbot;
std::wstring resbut; // can be result from middle frame or bottom frame

std::wstring reskeylef;
std::wstring reskeymid;
std::wstring reskeybot;

//std::vector<std::wstring> destmp; // text displayed in front of the input field
//std::vector<std::wstring> namtmp; // name of variable for programming purpose (ID we fetch to get content)
//std::vector<std::wstring> deftmp; // default value (the fill will be pre filled with this value)
//std::vector<std::wstring> typtmp; // type of data: textbox password
//std::vector<std::wstring> errtmp; // text to display after the form "facultatif" blue text "error" red text are special keywords
//std::vector<std::wstring> buttmp; // ok and cancel (usually)

//STDMETHODIMP CEventHandler::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)

class CEventHandler : public IDispatch
{
public:
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();

STDMETHODIMP GetTypeInfoCount(UINT *pctinfo);
STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);

CEventHandler(IHTMLWindow2 *pWindow2);

public:
LONG         m_cRef;
IHTMLWindow2 *m_pWindow2;
};
BOOL PutEventHandler(IHTMLDocument2 *pDocument2, IHTMLElement *pElement);
// ==================================
// MAIN
// ==================================
int _tmain(int argc, _TCHAR* argv[])
{
doevents();

// get console application handle to manage event in it
m_hWnd = FindWindow(NULL, L"ConsoleApplication1");

// IE 9.0.8112.16421: IEXPLORE.EXE
// Chrome 21.0.1180.60 m : Google Chrome
// Firefox 10.0.2 : FIREFOX.EXE
// Safari 3.2.2 : Safari.exe
// Opera 12.01 : Opera

// get default web browser path
std::string defaultbrowserpath01;
defaultbrowserpath01 = getdefaultbrowserpath();
//cout << defaultbrowserpath01;

HRESULT hr;
int dummy;

// these vectors contain data to dynamically generate buttons in left side frame
std::vector<std::wstring> arrbutnam; // name of button on left frame (also ID)
std::vector<std::wstring> arrbutdes; // description or caption
std::vector<std::wstring> arrdepnam; // sector (sectors have a space between them)
std::vector<std::wstring> arrdepcol; // button color of a sector

///////////////// project name
std::wstring project01 = L"test";

if (project01 == L"test")
{
// buttons specific to one project
arrbutnam.push_back(L"test");
arrbutdes.push_back(L"test button");
arrdepnam.push_back(L"TEST");
arrdepcol.push_back(L"cccccc");
}

// buttons in all of the project
arrbutnam.push_back(L"clrframes");
arrbutdes.push_back(L"Clear Frames");
arrdepnam.push_back(L"OTHER");
arrdepcol.push_back(L"cccccc");

arrbutnam.push_back(L"info");
arrbutdes.push_back(L"Information/Help");
arrdepnam.push_back(L"OTHER");
arrdepcol.push_back(L"cccccc");

arrbutnam.push_back(L"quit01");
arrbutdes.push_back(L"Quit");
arrdepnam.push_back(L"ALL");
arrdepcol.push_back(L"cccccc");

// create internet explorer windows and 3 frames: flef, fmid, fbot

dummy = create_web_main(&arrbutnam, &arrbutdes, &arrdepnam, &arrdepcol);

///////////////////////////////////////////////////////
// main LOOP
///////////////////////////////////////////////////////
//wcout <<L"\n\nwaiting for events, button click etc.";

// html form input parameters
std::vector<std::wstring> destmp; // description
std::vector<std::wstring> namtmp; // name of variable for programming purpose (ID we fetch to get content)
std::vector<std::wstring> deftmp; // default value (the fill will be pre filled with this value)
std::vector<std::wstring> typtmp; // type of data: textbox password
std::vector<std::wstring> errtmp; // text to display after the form "facultatif" blue text "error" red text are special keywords
std::vector<std::wstring> buttmp; // ok and cancel (usually)

do
{

if (resbutlef == L"test")
{
//Sleep(50);
clrfra(fmid);
clrfra(fbot);
resbutlef = L"";
resbutmid = L"";
resbutbot = L"";

dummy = writeln01(fbot, resbutlef);
dummy = writeln01(fbot, L"<br><br>");

// clear vectors
destmp.clear(); namtmp.clear(); deftmp.clear(); typtmp.clear(); errtmp.clear(); buttmp.clear();
// data to dynamically generate a input form
destmp.push_back(L"First name");
namtmp.push_back(L"text01");
deftmp.push_back(L"value 0");
typtmp.push_back(L"textbox");
errtmp.push_back(L"Enter first name please");

destmp.push_back(L"Last name");
namtmp.push_back(L"text02");
deftmp.push_back(L"value 1");
typtmp.push_back(L"textbox");
errtmp.push_back(L"Enter last name please");

buttmp.push_back(L"OK"); buttmp.push_back(L"Cancel");

std::wstring title01 = L"Test input";
// dynamic input form html generation
std::vector<std::wstring> results01; // will contain what is entered in html textboxes

results01 = dynforgen(fmid, &title01, &destmp, &namtmp, &deftmp, &typtmp, &errtmp, &buttmp);

if (resbut == L"OK")
{

clrfra(fmid);
for (int i = 0; i < results01.size(); i++)
{
dummy = writeln01(fbot, results01[i] + L"<br>");
}

dummy = writeln01(fbot, L"<br><br>FIN");
resbutlef = L"";
}
else
{
// cancel or a left button frame was pressed
clrfra(fmid);
// keep resbutlef with the value, so the action we did on left frame will execute in next loop
}
resbutmid = L"";
resbut = L"";
}

// common buttons
if (resbutlef == L"clrframes")
{
clrfra(fmid);
clrfra(fbot);
resbutlef = L"";
resbutmid = L"";
resbutbot = L"";
}

// info
if (resbutlef == L"info")
{
clrfra(fmid);
clrfra(fbot);
resbutlef = L"";
resbutmid = L"";
resbutbot = L"";

std::wstring arrhtm[] = {
L"INFORMATION / HELP",
L"SkynetCpp BETA",
L"2017-01-15",
L"-----",
L"Dynamic web interface to manage C++ programs",
L"By: sergefournier(@)hotmail.com",
L"Free to distribute",
L"----------",
L"Troubleshooting in visual studio 2013: in properties of the cpp console application, SELECT: use mfc in s shared DLL",
L"Troubleshooting in visual studio 2013 debug mode: copy this file near the .exe: mfc120ud.dll (windows 10)",
L""};

for (size_t i = 0; i < arrhtm[i].length(); i++)
{
dummy = writeln01(fbot, arrhtm[i]);
dummy = writeln01(fbot, L"<br>");
}

}
doevents();
} while (resbutlef != L"quit01");

// close internet explorer
//Sleep(50); // trying to prevent iexplore crash
pbrowser->Quit();
pbrowser->Release();

return 0;
}

IHTMLDocument2* gethtmele(IHTMLDocument2* phtmldoc2, std::wstring frame01)
{
// get frame object document to write in html frames
bool bSearch = true;
int hr;

// https://github.com/SeleniumHQ/selenium/blob/master/cpp/iedriver/DocumentHost.cpp
CComQIPtr<IHTMLFramesCollection2> frames;

hr = phtmldoc2->get_frames(&frames);
if (SUCCEEDED(hr) && (frames != NULL))
{
// get howmany frames
long length = 0;
hr = frames->get_length(&length);

if (SUCCEEDED(hr) && length > 0)
{
CComVariant frame_identifier = NULL;
frame_identifier = frame01.c_str();

CComVariant frame_holder = NULL;
hr = frames->item(&frame_identifier, &frame_holder);
if (SUCCEEDED(hr))
{
/// get frame content
IHTMLWindow2* interim_result;
hr = frame_holder.pdispVal->QueryInterface<IHTMLWindow2>(&interim_result);

if (SUCCEEDED(hr))
{
IDispatch* pIHTMLDoc;
hr = interim_result->get_document((IHTMLDocument2 **)&pIHTMLDoc);

if (SUCCEEDED(hr))
{
IHTMLDocument2* frameele = NULL;
hr = pIHTMLDoc->QueryInterface(IID_IHTMLDocument2, (void**)&frameele);
if (SUCCEEDED(hr))
{
//int dummy = writeln01(frameele, L"TEST222");
return frameele;
}
else
{
wcout << L"\n";
cout << "ERROR getting IHTMLDocument2";
}
}
else
{
wcout << L"\n";
cout << "ERROR getting pointer to IHTMLDocument2";
}
}
else
{
wcout << L"\n";
cout << "ERROR getting window pointer";
}
}
else
{
wcout << L"\n";
cout << "ERROR did not find any frame named: ";
wcout << frame01;
}
}
else
{
wcout << L"\n";
cout << "ERROR get_length(&length) - number of frames is 0)";
}
}
else
{
wcout << L"\n";
cout << "ERROR get_frames(&frames) - no frame collection found";
}

}
int create_web_main(std::vector<std::wstring>* arrbutnam,
std::vector<std::wstring>* arrbutdes,
std::vector<std::wstring>* arrdepnam,
std::vector<std::wstring>* arrdepcol)
{
// vector https://msdn.microsoft.com/en-us/library/9xd04bzs.aspx

int dummy;

//cout<< arrbutnam[0];

if (SUCCEEDED(OleInitialize(NULL)))
{
CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER, IID_IWebBrowser2, (void**)&pbrowser);
if (pbrowser)
{
VARIANT vEmpty;
VariantInit(&vEmpty);

BSTR bstrURL = SysAllocString(L"about:blank");

HRESULT hr = pbrowser->Navigate(bstrURL, &vEmpty, &vEmpty, &vEmpty, &vEmpty);
if (SUCCEEDED(hr))
{
pbrowser->put_Left(20);
pbrowser->put_Top(10);
pbrowser->put_Height(1000); // 1080
pbrowser->put_Width(1900); // 1920

int test = 0;
if (test == 1)
{
pbrowser->put_Left(700);
pbrowser->put_Top(10);
pbrowser->put_Height(1000); // 1080
pbrowser->put_Width(1200); // 1920

}

pbrowser->put_AddressBar(VARIANT_TRUE);
pbrowser->put_MenuBar(VARIANT_FALSE);
pbrowser->put_ToolBar(VARIANT_FALSE);
// pHtmlDoc->put_title(BSTR("SkyNet30"));
// pHtmlDoc->put_URL(BSTR("www.google.com"));
// pHtmlDoc->execCommand(BSTR("RELOAD"));
pbrowser->put_Visible(VARIANT_TRUE);

if (WaitTillLoaded(12)) /// wait 12 tick of 250 ms to expire
{
// printf("\nready in time");
HRESULT hr;
IDispatch* pHtmlDocDispatch = NULL;
pHtmlDoc = NULL;

// Retrieve the document object.
hr = pbrowser->get_Document(&pHtmlDocDispatch);
if (SUCCEEDED(hr) && (pHtmlDocDispatch != NULL))
{
hr = pHtmlDocDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&pHtmlDoc);

if (SUCCEEDED(hr) && (pHtmlDoc != NULL))
{
//printf("\ngot a DOC");

// internet explorer interface will use 3 frames
std::wstring arrhtm[] = {
L"<HTML>",
L"<HEAD><TITLE>SkynetCPP</TITLE>",
L"<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\">",
L"<meta http-equiv=\"X-UA-Compatible\" content=\"IE=8\">",
L"</HEAD>",
L"<FRAMESET id='main' COLS=\"13%, *\">",
L"<FRAME SRC=\"About:Blank\" NAME=\"flef\" id=\"flef\">",
L"<frameset id='main2' rows=\"30%,70%\">",
L"<FRAME SRC=\"About:Blank\" NAME=\"fmid\" id=\"fmid\">",
L"<FRAME SRC=\"About:Blank\" NAME=\"fbot\" id=\"fbot\">",
L"</FRAMESET>",
L"</frameset>",
L"</HTML>" };

for (size_t i = 0; i < arrhtm[i].length(); i++)
{
dummy = writeln01(pHtmlDoc, arrhtm[i]);
}

pbrowser->Refresh();

// IHTMLDocument2* flef;
flef = gethtmele(pHtmlDoc, L"flef");
//IHTMLDocument2* fmid;
fmid = gethtmele(pHtmlDoc, L"fmid");
//IHTMLDocument2* fbot;
fbot = gethtmele(pHtmlDoc, L"fbot");

/////////////////////////////// buttons generation (html) in left frame

std::wstring departement;
std::wstring lasdep;
std::wstring html;

for (int i = 0; i < (*arrbutnam).size(); i++)
{
html = L"<input type=\"button\" style=\"height:50px;font-size:14px;width:100%;white-space: normal;\" id=\"" + (*arrbutnam)[i] + L"\" name=\"" + (*arrbutnam)[i] + L"\" value=\"" + (*arrbutdes)[i] + L"\"";
int i2 = i;

if (i>(*arrdepnam).size())
i2 = (*arrdepnam).size();
else
departement = (*arrdepnam)[i2];

if (departement != lasdep)
{
lasdep = departement;
dummy = writeln01(flef, L"<br>" + departement + L"<br>");
}
html += L" style=\"background-color: #" + (*arrdepcol)[i2] + L"; color: #000000;\"><br>";
dummy = writeln01(flef, html);
}

// find input elements in frame
// define event for that button
bool success01 = FALSE;
IHTMLElement* pElem = NULL;
for (int i = 0; i < (*arrbutnam).size(); i++)
{
pElem = findhtmlelement(flef, L"INPUT", (*arrbutnam)[i]);
success01 = PutEventHandler(flef, pElem);
//wcout << "event ";
}

//OleUninitialize(); // cant do that, or event stop working
return 0;
} // hr = pHtmlDocDispatch->QueryInterface(IID_IHTMLDocument2
} // hr = pbrowser->get_Document(&pHtmlDocDispatch);
} // waittill loaded (not always working)
} // HRESULT hr = pbrowser->Navigate(
} //CoCreateInstance(CLSID_InternetExplorer
//OleUninitialize();
}
else
{
// oleinitialize failed
wcout << L"\n";
wcout << L"failed ole initialize";
}
}

// GOOD FULL CODE
// http://eternalwindows.jp/browser/mshtml/mshtml07.html
CEventHandler::CEventHandler(IHTMLWindow2 *pWindow2)
{
m_cRef = 1;
m_pWindow2 = pWindow2;
}

STDMETHODIMP CEventHandler::QueryInterface(REFIID riid, void **ppvObject)
{
*ppvObject = NULL;

if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IDispatch))
*ppvObject = static_cast<IDispatch *>(this);
else
return E_NOINTERFACE;

AddRef();

return S_OK;
}

STDMETHODIMP_(ULONG) CEventHandler::AddRef()
{
return InterlockedIncrement(&m_cRef);
}

STDMETHODIMP_(ULONG) CEventHandler::Release()
{
if (InterlockedDecrement(&m_cRef) == 0) {
delete this;
return 0;
}

return m_cRef;
}

STDMETHODIMP CEventHandler::GetTypeInfoCount(UINT *pctinfo)
{
*pctinfo = 0;

return S_OK;
}

STDMETHODIMP CEventHandler::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
{
return E_NOTIMPL;
}

STDMETHODIMP CEventHandler::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
return E_NOTIMPL;
}

STDMETHODIMP CEventHandler::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
// event called when you press a html input button in html frame
BSTR          bstr;
IHTMLEventObj *pEventObj;
IHTMLElement  *pElement;
BSTR id01;
BSTR frame02;
std::wstring frame11;

m_pWindow2->get_event(&pEventObj);
pEventObj->get_srcElement(&pElement);
pElement->get_tagName(&bstr);
pElement->get_id(&id01); // name of button that was pressed
m_pWindow2->get_name(&frame02);

frame11 = frame02;

//wcout<< frame01;

//MessageBoxW(NULL, bstr, L"bouton presse", MB_OK);

//BSTR to std::wstring:
// given BSTR bs
assert(id01 != nullptr);
std::wstring ws(id01, SysStringLen(id01));

//std::wstring to BSTR :
// given std::wstring ws
//assert(!ws.empty());
//BSTR bs = SysAllocStringLen(ws.data(), ws.size());

//MessageBox(NULL, TEXT("test"), TEXT("OK"), MB_OK);
if (frame11 == L"flef")
resbutlef = id01;
if (frame11 == L"fmid")
resbutmid = id01;
if (frame11 == L"fbot")
resbutbot = id01;

SysFreeString(bstr);
pElement->Release();
pEventObj->Release();

return S_OK;
}
void doevents()
{
MSG Msg;
BOOL bRet;
//HICON
//analog DoEvents() v VB
if (PeekMessage(&Msg, m_hWnd, 0, 0, PM_NOREMOVE))
{
if ((bRet = GetMessage(&Msg, m_hWnd, 0, 0)))
DispatchMessage(&Msg);
}
}
BOOL PutEventHandler(IHTMLDocument2* pDocument2, IHTMLElement* pElement)
{
// generate event handler associated with a html button in internet explorer frame

//wcout << L"\nstart puteventhandler";

//BSTR           bstrId;
VARIANT        var;
//IHTMLElement   *pElement;
//IHTMLDocument2 *pDocument2;
IHTMLWindow2   *pWindow2;
HRESULT hr;
IHTMLDocument3* pDocument3;

// bstrId = SysAllocString(L"test");
//hr = pDocument3->getElementById(bstrId, &pElement);

hr = pDocument2->QueryInterface(IID_PPV_ARGS(&pDocument3));
if (SUCCEEDED(hr) && pDocument3 != NULL)
{
//pDocument3->QueryInterface(IID_PPV_ARGS(&pDocument2));
hr = pDocument2->get_parentWindow(&pWindow2);
if (SUCCEEDED(hr) && pWindow2 != NULL)
{
var.vt = VT_DISPATCH;
var.pdispVal = new CEventHandler(pWindow2);
if (pElement != NULL)
{
hr = pElement->put_onclick(var);
if (SUCCEEDED(hr))
{
//MessageBox(NULL, TEXT("test"), TEXT("OK"), MB_OK);

//SysFreeString(bstrId);
var.pdispVal->Release();
pWindow2->Release();
//pDocument2->Release();
pElement->Release();

return TRUE;
}
else
{
wcout << L"\nERROR PutEventHandler event not defined";
return FALSE;
}
}
else
{
wcout << L"\nERROR PutEventHandler pElement is NULL";
return FALSE;
}


}
else
{
wcout << L"\nERROR PutEventHandler getting pWindow2";
return FALSE;
}
}
else
{
wcout <<L"\nERROR PutEventHandler IHTMLDocument3";
return FALSE;
}
}


IHTMLElement* findhtmlelement(IHTMLDocument2 *fra, std::wstring type01, std::wstring name01)
{
bool bSearch = true;
HRESULT hr;

// scan doc object collection in html document
IHTMLElementCollection* pColl = NULL;
hr = fra->get_all(&pColl);
if (SUCCEEDED(hr) && (pColl != NULL))
{
// Obtained the Anchor Collection...
long nLength = 0;
pColl->get_length(&nLength);

for (int i = 0; i < nLength && bSearch; i++)
{
COleVariant vIdx((long)i, VT_I4);
IDispatch* pElemDispatch = NULL;
IHTMLElement * pElem = NULL;

hr = pColl->item(vIdx, vIdx, &pElemDispatch);

if (SUCCEEDED(hr) && (pElemDispatch != NULL))
{
hr = pElemDispatch->QueryInterface(IID_IHTMLElement, (void**)&pElem);

if (SUCCEEDED(hr) && (pElem != NULL))
{
BSTR bstrTagName;
std::wstring sTempTagName = L"";
hr = pElem->get_tagName(&bstrTagName);
if (SUCCEEDED(hr) && (bstrTagName != NULL))
{

// conversion error
sTempTagName = bstrTagName;
//SysFreeString(bstrTagName);

BSTR bstrtagid = NULL;
hr = pElem->get_id(&bstrtagid);
if (bstrtagid != NULL)
{

std::wstring stemptagid = L"";

stemptagid = bstrtagid;

if ((sTempTagName == type01) && (stemptagid == name01))
{
//wcout << L"\n Type wanted: ";
//wcout << type01;
//wcout << L"   Name wanted: ";
//wcout << name01;

//pElemDispatch->Release();
return pElem;
}
} // get_id(&bstrtagid) (id of button)
} // if get_tagname
} //if (SUCCEEDED(hr) && (pElem != NULL))
} //if (SUCCEEDED(hr) && (pElemDispatch != NULL))
} //for (int i = 0; i < nLength && bSearch; i++)
} //if (SUCCEEDED(hr) && (pColl != NULL))
}

std::string getdefaultbrowserpath()
{
// get executable path to defaut browser (not working very well in windows 10)
// modified from http://www.codeproject.com/internet/urlnewwindow.asp
std::string page;
std::wstring wstrBrowser01;
std::string str01;

HKEY hKey = NULL;

// get defaut internet browser
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, TEXT("http\\shell\\open\\command"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
DWORD cbData = 0;
if (RegQueryValueEx(hKey, NULL, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS && cbData > 0)
{
// command key is present
TCHAR* browsername01 = new TCHAR[cbData];
if (browsername01 != NULL)
{

if (RegQueryValueEx(hKey, NULL, NULL, NULL, (LPBYTE)browsername01, &cbData) == ERROR_SUCCESS)
//if (RegQueryValueEx(hKey, NULL, NULL, NULL, reinterpret_cast<LPBYTE>(&browsername01[0]), &cbData) == ERROR_SUCCESS)
{
wstrBrowser01 = browsername01;
// wcout << wstrBrowser01;
}
delete[] browsername01;
}
}
RegCloseKey(hKey);
}
else
{
//printf("\r\nERROR could not read regkey");
}

// get path of executable and remove stuff around it
if (wstrBrowser01.length() > 0)
{
std::string::size_type nStart = wstrBrowser01.find('"', 0);

// if first is a quote, then exe path is in quotes, so find the second quote
if (nStart == 0)
{
std::string::size_type nEnd = wstrBrowser01.find('"', 1);
if (nStart != nEnd && nEnd != std::string::npos)
{
wstrBrowser01 = wstrBrowser01.substr(nStart + 1, nEnd - nStart - 1);
}
}
// otherwise if no quotes, 2nd point is the first space after the last backslash
else
{
std::string::size_type nIndex = wstrBrowser01.rfind('\\', wstrBrowser01.length() - 1);
if (nIndex != std::string::npos)
{
std::string::size_type nSpace = wstrBrowser01.find(' ', nIndex);
if (nSpace != std::string::npos)
{
wstrBrowser01 = wstrBrowser01.substr(0, nSpace);
}
}
}

std::wstring wcommand01 = L"\"";
wcommand01 += wstrBrowser01;
wcommand01 += L"\"";
std::string arg01 = "\"";
arg01 += "www.google.ca";
arg01 += "\"";

std::string command01(wcommand01.begin(), wcommand01.end());

//printf("\n");
//printf("default browser: ");
//printf(command01.c_str());

// HINSTANCE hinst01 = ShellExecuteW(NULL, L"open", LPCWSTR(wcommand01.c_str()), NULL, NULL, SW_HIDE);
//HINSTANCE hinst01 = ShellExecuteA(NULL, "Open", LPCSTR(command01.c_str()), LPCSTR(arg01.c_str()), NULL, 3);
//printf("\n");
//cout << hinst01;

// link handle to application

// COleVariant loc(L"about:blank");
// m_explorer.Navigate2("about:blank", NULL, NULL, NULL, NULL);
// IDispatch* pHtmlDoc = m_explorer.get_Document();
return command01.c_str();
}
else
{
//printf("\r\n\r\nERROR strBrowser01.length is 0");


}
}


int writeln01(IHTMLDocument2* phtmldoc1, std::wstring string01)
{
// write wstring to a html frame
SAFEARRAYBOUND bounds[] = { { 1, 0 } }; //Array Contains 2 Elements starting from Index ‘0’
SAFEARRAY* safearray01 = SafeArrayCreate(VT_VARIANT, 1, bounds); //Create a one-
long lIndex[1];
VARIANT var;
lIndex[0] = 0; // index of the element being inserted in the array
var.vt = VT_BSTR; // type of the element being inserted

//var.bstrVal = ::SysAllocStringLen(L"<br>The<br>First String", 16); // the value of the element being inserted
var.bstrVal = ::SysAllocStringLen(string01.c_str(), string01.length()); // the value of the element being inserted
HRESULT hr = SafeArrayPutElement(safearray01, lIndex, &var); // insert the element
//if (WaitTillLoaded(0)== TRUE)
//{
phtmldoc1->writeln(safearray01);
//}

return 0;
}

bool WaitTillLoaded(int nTimeout)
{
// wait till internet explorer is ready to receive stuff
READYSTATE result;
DWORD nFirstTick = GetTickCount();

do
{
pbrowser->get_ReadyState(&result);

if (result != READYSTATE_COMPLETE)
{
Sleep(100);
}
if (nTimeout > 0)
{
if ((GetTickCount() - nFirstTick) > nTimeout)
{
break;
}
}
} while (result != READYSTATE_COMPLETE);

if (result == READYSTATE_COMPLETE)
{
//cout << "true";
return TRUE;
}
else
{
//cout << "false";
return FALSE;
}
}

std::vector<std::wstring> dynforgen(IHTMLDocument2* fra, std::wstring *title01,
std::vector<std::wstring>* destmp,
std::vector<std::wstring>* namtmp,
std::vector<std::wstring>* deftmp,
std::vector<std::wstring>* typtmp,
std::vector<std::wstring>* errtmp,
std::vector<std::wstring>* buttmp)
{
std::vector<std::wstring> olderrtmp;
olderrtmp = (*errtmp);

// html content
int dummy;
int deffoc;
std::wstring col;
std::wstring type01;
std::wstring wname01;
std::string name01;
IHTMLWindow2 *window01;
BSTR framename01;
std::wstring wframename01;
BSTR text01;
std::wstring wvalue01;
std::vector<std::wstring> results01;

// get windows of the frame document
fra->get_parentWindow(&window01);
// get frame name to be able to manage any button pressed if the bottom or mid frame is used
window01->get_name(&framename01);
wframename01 = framename01;

// do all the input process with inner html
IHTMLElement *p = NULL;
// get inner html body
fra->get_body(&p);
if (p)
{
BOOL valid01 = FALSE;
resbut = L"";
do
{
//wcout<< L"\n restarting inputs";

clrfra(fra); // clear frame

std::wstring h = L"";

// title with bigger letters
h = L"<h3><span class=SpellE>" + *title01 + L"</span></h3>";

for (int i = 0; i < (*destmp).size(); i++)
{
// focus on first empty field
deffoc = 0;
if ((*deftmp)[i] == L"")
{
if ((*errtmp)[i] != L"falcultatif")
{
h += L"<BODY onLoad=\"document.form01." + (*namtmp)[i] + L".focus()\">";
deffoc = 1;
}
}
}

if (deffoc == 0)
{
// if no empty field just focus on first element
h += L"<BODY onLoad=\"document.form01." + (*namtmp)[0] + L".focus()\">";
}

h += L"<div class=MsoNormal align=center style='text-align:center'>";
h += L"</div>";

h += L"<form name=form01>";

for (int i = 0; i < (*namtmp).size(); i++)
{
h += (*destmp)[i] + L": ";

h += L"<input type=\"" + (*typtmp)[i] + L"\" ";
h += L"id=" + (*namtmp)[i] + L" ";
h += L"NAME=\"" + (*namtmp)[i] + L"\" ";
h += L"size=\"" + (*deftmp)[i] + L"\" ";
h += L"value=\"" + (*deftmp)[i] + L"\" ";
h += L"onKeypress=\"return event.keyCode!=13\"";

if ((*errtmp)[i].find(L"ERROR"))
col = L"blue";
else
col = L"red";
h += L"&nbsp; <b><span style='color:" + col + L"'>&nbsp" + (*errtmp)[i] + L"</span></b><br style='mso-special-character:line-break'>";
}
h += L"<![if !supportLineBreakNewLine]><br style='mso-special-character:line-break'>";
h += L"<![endif]></p>";

for (int i = 0; i < (*buttmp).size(); i++)
{
// ok button and cancel button
type01 = L"button";
h += L"<input type=\"" + type01 + L"\" id=\"" + (*buttmp)[i] + L"\" name=\"" + (*buttmp)[i] + L"\" ";
h += L"value=\"&nbsp;" + (*buttmp)[i] + L"&nbsp;\">";
h += L"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
//html = L"<input type=\"button\" style=\"height:50px;font-size:14px;width:100%;white-space: normal;\" "
//"id=\"" + arrbutnam[i] + L"\" name=\"" + arrbutnam[i] + L"\" value=\"" + arrbutdes[i] + L"\"";
}

h += L"</div>";
h += L"</form>";
h += L"</body>";
h += L"</html>";

h += L"";

//std::wstring to BSTR //given std::wstring h
BSTR bs = SysAllocStringLen(h.c_str(), h.size());
p->put_innerHTML(bs);

// define events for OK and Cancel buttons
for (int i = 0; i < (*buttmp).size(); i++)
{
bool success01 = FALSE;
IHTMLElement* pElem = NULL;
//wcout << L"\n" + buttmp[i];

pElem = findhtmlelement(fra, L"INPUT", (*buttmp)[i]);
success01 = PutEventHandler(fra, pElem);

}

// wait for ok, cancel or anything on left frame to exit this section
if (wframename01 == L"fmid")
{
resbutmid = L"";
reskeymid = L"";
}
if (wframename01 == L"fbot")
{
resbutbot = L"";
reskeybot = L"";
}
do
{
// the form can be in two frames, so we get button result from any and put it in a generic button variable
doevents();
if (wframename01 == L"fmid")
resbut = resbutmid;
if (wframename01 == L"fbot")
resbut = resbutbot;

//wcout <<L"\n resbutlef: ";
Sleep(50);
// loop until ok or cancel os pressed OR a button in left menu is used to exit the input sequence
} while ((resbut != L"Cancel") && (resbut != L"OK") && (resbutlef.size() == 0));

doevents();

// get value entered in web form and put them in a vector as strings
if ((resbut != L"Cancel") && (resbutlef.size() == 0))
{

type01 = L"INPUT";
// result vector wstring
results01.clear();
int validcnt01 = 0;

for (int i = 0; i < (*namtmp).size(); i++)
{
wname01 = (*namtmp)[i];
// pelem = findhtmlelement(fra, type01, name01);

// convert wstring to BSTR
//assert(!wname01.empty());
BSTR bstrname01 = NULL;
bstrname01 = SysAllocStringLen(wname01.c_str(), wname01.size());

// get inputtext html elements (textbox) element by name
IHTMLInputTextElement* peleminput = NULL;

//_variant_t varName(bstrname01); // textbox id / name
//_variant_t varIdx(0L);
// change to:
//COleVariant vIdx((long)i, VT_I4);
COleVariant varName(bstrname01); // textbox id / name
COleVariant varIdx(0L);
HRESULT hr;
IDispatch* pElemDisp = NULL;

IHTMLElementCollection* pcoll = NULL;
hr = fra->get_all(&pcoll);
if (SUCCEEDED(hr) && (pcoll != NULL))
{
hr = pcoll->item(varName, varIdx, &pElemDisp);
if (SUCCEEDED(hr) && (pElemDisp != NULL))
{
// get inputtext html elements (textbox) content
hr = pElemDisp->QueryInterface(IID_IHTMLInputTextElement, (void**)&peleminput);
if (SUCCEEDED(hr))
{
peleminput->get_value(&text01);
if (text01 != NULL)
{
wvalue01 = text01; // convert to wstring
validcnt01++; // result is longer than 1 char, so it is probably valid
(*errtmp)[i] = olderrtmp[i]; //put initial text
}
else
{
wvalue01 = L"";
(*errtmp)[i] = L"ERROR must enter one character";
}
results01.push_back(wvalue01);
(*deftmp)[i] = wvalue01;
}
}
}
}

// validate all results must be at least 1 char long
//errtmp[i] ERROR text must be in it to be RED

if (validcnt01 == (*namtmp).size())
valid01 = TRUE;
else
valid01 = FALSE;
//wcout <<L"\n";
//wcout << validcnt01;
}
doevents();
} while ((valid01 == FALSE) && (resbut != L"Cancel") && (resbutlef.size() == 0)); // validate the string, if not valid, remake form and input again
doevents();
} // get body

// reset button and keys states
if (wframename01 == L"fmid")
{
resbutmid = L"";
reskeymid = L"";
}

if (wframename01 == L"fbot")
{
resbutbot = L"";
reskeybot = L"";
}

return results01;
}


void clrfra(IHTMLDocument2 *fra)
{
// clear bottom html frame
BSTR bstrContent = NULL;
IHTMLElement *p = NULL;

fra->get_body(&p);
int ii = 20;
if (p)
{

do
{
doevents();

try
{
p->put_innerHTML(L"");
//p->get_innerHTML(&bstrContent);
ii = 0;
}
catch (int e)
{
Sleep(50);
ii--;
}
} while (ii > 0);
p->Release();
}
}

Friday, December 30, 2016

unattended windows 10 usb installation français Canada

unattended windows 10 usb installation français Canada

2017-07-29
autounattend.xml script generation
http://wildboy85.blogspot.ca/2017/07/autounattend-xml-file-generation-with.html

powershell script to remove unwanted apps (for work computers)
http://wildboy85.blogspot.ca/2017/07/powershell-script-to-clean-unwanted.html

2017-07-27 9:50

Changed for usb key to boot BIOS and UEFI
1. This should generate a windows 10 build 1703, without patches (4 + 1 for defender at this date)
2. Make a usb key with MediaCreationTool.exe from microsoft
   https://www.microsoft.com/en-ca/software-download/windows10
3. Copy the content of the usb key created by MediaCreationTool in c:\win10una1703frapro_work
4. Assume usb  key is Z:
5. Assume C:\win10una1703frapro_work\sources\$oem$\$1 is where you keep the personalized files for your windows installation (the files autounattend.xml use during installation)
6. Copy C:\win10una1703frapro_work\sources\$oem$\$1 to Z:\sources\$oem$\$1
7. Copy C:\win10una1703frapro_work\autounattend.xml to Z:\
8. Use DISM to integrate the latest patches in the install.wim file:
   C:\win10una1703frapro_work\sources\install.wim
9. Split the install.wim with DISM if it is bigger that 4 gig
10. If you use a splitted file for windows image:
   Delete C:\win10una1703frapro_work\sources\install.wim
   Copy your splitted files in C:\win10una1703frapro_work\sources\
11. Copy mirror purge C:\win10una1703frapro_work\ to Z: with robocopy
12. The key will not wipe disk 0 automatically anymore (UEFI prevent that automation)
   So if "willwipedisk" if in your autounattend filoe, remove it
13. The image from microsoft will contain 3 windows versions, use the image index to select pro version (index 1 is pro)
14. The key should work fine (tested in BIOS and UEFI, secureboot off)
15. i Also programmed a autounattend.xml generator (in vbs) for the sequence of synchronous command to be... sequential, and cleaner

2016-12-31 22:19

java runtime update (jre)
google chrome 64 bits update
k-lite codec update
privacy setting added in a .bat
no usb indexing added in policies (by reg key)
control pannel classic display

Hi,

Here is a usb unattended installation of windows 10 pro french Canada

Voici l'installation sans attention (pas besoin de cliquer) de windows 10 professionnel français Canada

1.
This usb key will WIPE disk 0 (connector 0 on the main board)

2.
Not working on EFI bios installation aka secure boot (failed to create partition 0)

3.
It will install avast antivirus and office 2013 and acrobat reader or pro etc.

4.
There is no drivers automated in it, since updating drivers online is working fine with windows 10

5.
Put this unattend file in the root of a usb key that contain windows 10 dvd content

Acrobat did not want to install on first pass, I had to do it after a reboot

All folder from usb key in this folder:
\sources\$oem$\$1\
Are copied on c:\ by windows

The BAT file running after first reboot is:
c:\_updates\phase02_acrobat_pro.bat
The phase02*.bat will then write in registry the next .BAT to run after next reboot

------ c:\_updates\phase02.bat (originally in sources\$oem$\$1\_updates directory on key) -------
rem === acrobat reader after reboot installation
c:
cd c:\_appsall\acrobat_reader_adobe
for /F %%A in ('dir /b *.exe') do start /wait %%A /sPB /rs

reg add HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v NewSetupScript /t Reg_SZ /d "c:\_updates\phase03.bat" /f
---------------------- end of file ---------------------

-------------------------- phase03.bat ---------------------------

cmd.exe /c c:\_appsmaison\antivirus\avast_free_antivirus_setup.exe /silent /NORESTART /SP- /"Chrome"="false"

rem clean desktop
del "C:\Users\Public\Desktop\Avast SafeZone Browser.lnk"
del "C:\Users\Public\Desktop\Avast Antivirus Gratuit.lnk"

reg add HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v NewSetupScript /t Reg_SZ /d "c:\_updates\phase05_privacy.bat" /f

rem reboot

Shutdown /r /t 30

---------------------- end of file ---------------------

-------------------- autounattend.xml ----------------------------

<?xml version="1.0" encoding="UTF-8"?>

-<unattend xmlns="urn:schemas-microsoft-com:unattend">


-<settings pass="windowsPE">


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-International-Core-WinPE">


-<SetupUILanguage>

<UILanguage>fr-FR</UILanguage>

</SetupUILanguage>

<InputLocale>0c0c:00001009</InputLocale>

<SystemLocale>fr-FR</SystemLocale>

<UILanguage>fr-FR</UILanguage>

<UILanguageFallback>fr-FR</UILanguageFallback>

<UserLocale>fr-CA</UserLocale>

</component>


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-Setup">


-<ImageInstall>


-<OSImage>


-<InstallFrom>


-<MetaData wcm:action="add">

<Value>1</Value>

<key>/IMAGE/INDEX</key>

</MetaData>

</InstallFrom>

<InstallToAvailablePartition>false</InstallToAvailablePartition>

<WillShowUI>OnError</WillShowUI>

</OSImage>

</ImageInstall>


-<UserData>

<AcceptEula>true</AcceptEula>

<FullName>Maison</FullName>


-<ProductKey>

<Key>W269N-WFGWX-YVC9B-4J6C9-T83GX</Key>

</ProductKey>

</UserData>

<EnableFirewall>true</EnableFirewall>

</component>

</settings>


-<settings pass="offlineServicing">


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-LUA-Settings">

<EnableLUA>false</EnableLUA>

</component>

</settings>


-<settings pass="generalize">


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-Security-SPP">

<SkipRearm>1</SkipRearm>

</component>

</settings>


-<settings pass="specialize">


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-International-Core">

<InputLocale>0c0c:00001009</InputLocale>

<SystemLocale>fr-CA</SystemLocale>

<UILanguage>fr-CA</UILanguage>

<UILanguageFallback>fr-CA</UILanguageFallback>

<UserLocale>fr-CA</UserLocale>

</component>


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-Security-SPP-UX">

<SkipAutoActivation>true</SkipAutoActivation>

</component>


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-SQMApi">

<CEIPEnabled>0</CEIPEnabled>

</component>


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-Shell-Setup">

<ProductKey>W269N-WFGWX-YVC9B-4J6C9-T83GX</ProductKey>

</component>

</settings>


-<settings pass="oobeSystem">


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-Shell-Setup">


-<AutoLogon>


-<Password>

<Value/>

<PlainText>true</PlainText>

</Password>

<Enabled>true</Enabled>

<Username>Maison</Username>

</AutoLogon>


-<OOBE>

<HideEULAPage>true</HideEULAPage>

<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>

<HideOnlineAccountScreens>true</HideOnlineAccountScreens>

<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>

<NetworkLocation>Home</NetworkLocation>

<SkipUserOOBE>true</SkipUserOOBE>

<SkipMachineOOBE>true</SkipMachineOOBE>

<ProtectYourPC>2</ProtectYourPC>

</OOBE>


-<UserAccounts>


-<LocalAccounts>


-<LocalAccount wcm:action="add">


-<Password>

<Value/>

<PlainText>true</PlainText>

</Password>

<Description>Utilisateuradmin</Description>

<DisplayName>Maison</DisplayName>

<Group>Administrators</Group>

<Name>Maison</Name>

</LocalAccount>

</LocalAccounts>

</UserAccounts>

<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>


-<FirstLogonCommands>


-<SynchronousCommand wcm:action="add">

<Description>klite and media classic player any version</Description>

<Order>1</Order>

<CommandLine>cmd /c c:\_appsall\7zip\commandline.bat</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>explorer open in this PC</Description>

<Order>2</Order>

<CommandLine>REG ADD "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v LaunchTo /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>java</Description>

<Order>3</Order>

<CommandLine>cmd /c c:\_appsall\java_sun\commandline.bat</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>video codec and media player classic</Description>

<Order>4</Order>

<CommandLine>cmd /c c:\_appsall\video_codecs_convert\commandline.bat</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>vcredist</Description>

<Order>5</Order>

<CommandLine>cmd.exe /c "c:\_appsall\vcredist2010sp1\vcredist_x86.exe" /q /norestart</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>vcredist</Description>

<Order>6</Order>

<CommandLine>cmd.exe /c "c:\_appsall\vcredist2010sp1\vcredist_x64.exe" /q /norestart</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>vcredist</Description>

<Order>7</Order>

<CommandLine>cmd.exe /c "c:\_appsall\vcredist2012upd4\vcredist_x86.exe" /q /norestart</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>vcredist</Description>

<Order>8</Order>

<CommandLine>cmd.exe /c "c:\_appsall\vcredist2012upd4\vcredist_x64.exe" /q /norestart</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>vcredist</Description>

<Order>9</Order>

<CommandLine>cmd.exe /c "c:\_appsall\vcredist2013\vcredist_x64.exe" /q /norestart</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>vcredist</Description>

<Order>10</Order>

<CommandLine>cmd.exe /c "c:\_appsall\vcredist2013\vcredist_x86.exe" /q /norestart</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>vcredist</Description>

<Order>11</Order>

<CommandLine>cmd.exe /c "c:\_appsall\vcredist2015\vc_redist.x86.exe" /q /norestart</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>vcredist</Description>

<Order>12</Order>

<CommandLine>cmd.exe /c "c:\_appsall\vcredist2015\vc_redist.x64.exe" /q /norestart</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>vcredist 2017</Description>

<Order>13</Order>

<CommandLine>cmd.exe /c "c:\_appsall\vcredist2017\vc_redist.x64.exe" /q /norestart</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>removable drive index</Description>

<Order>14</Order>

<CommandLine>cmd /c reg add "HKLM\Software\Policies\Microsoft\Windows\Windows Search" /v DisableRemovableDriveIndexing /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>chrome 64</Description>

<Order>15</Order>

<CommandLine>cmd /c c:\_appsall\chrome\chromeStandaloneSetup64.exe /silent /install</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>defender patch</Description>

<Order>16</Order>

<CommandLine>cmd /c c:\_updates\defender\commandline.bat</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>drivers search path c drivers</Description>

<Order>17</Order>

<CommandLine>cmd /c reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion" /v DevicePath /t REG_EXPAND_SZ /d %SystemRoot%\inf;c:\_drivers /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>blue screen crash reboot</Description>

<Order>18</Order>

<CommandLine>cmd /c reg add "HKLM\SYSTEM\CurrentControlSet\Control\CrashControl" /v AutoReboot /t REG_DWORD /d 0 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>blue screen crash</Description>

<Order>19</Order>

<CommandLine>cmd /c reg add "HKLM\SYSTEM\CurrentControlSet\Control\CrashControl" /v AUState /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>windows update</Description>

<Order>20</Order>

<CommandLine>cmd /c reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>notepad2 vbs edit</Description>

<Order>21</Order>

<CommandLine>cmd /c reg add "HKLM\SOFTWARE\Classes\VBSFile\Shell\Edit\command" /v "" /t REG_SZ /d "C:\WINDOWS\System32\Notepad2.exe %1" /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>notepad2 edit</Description>

<Order>22</Order>

<CommandLine>cmd /c reg add "HKLM\SOFTWARE\Classes\txtFile\Shell\Edit\command" /v "" /t REG_SZ /d "C:\WINDOWS\System32\Notepad2.exe %1" /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>notepad2 edit</Description>

<Order>23</Order>

<CommandLine>cmd /c reg add "HKLM\SOFTWARE\Classes\batFile\Shell\Edit\command" /v "" /t REG_SZ /d "C:\WINDOWS\System32\Notepad2.exe %1" /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>notepad2 edit</Description>

<Order>24</Order>

<CommandLine>cmd /c reg add "HKLM\SOFTWARE\Classes\regFile\Shell\Edit\command" /v "" /t REG_SZ /d "C:\WINDOWS\System32\Notepad2.exe %1" /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>notepad2 edit</Description>

<Order>25</Order>

<CommandLine>cmd /c reg add "HKLM\SOFTWARE\Classes\cmdFile\Shell\Edit\command" /v "" /t REG_SZ /d "C:\WINDOWS\System32\Notepad2.exe %1" /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>notepad2 edit</Description>

<Order>26</Order>

<CommandLine>cmd /c reg add "HKLM\SOFTWARE\Classes\xmlFile\Shell\Edit\command" /v "" /t REG_SZ /d "C:\WINDOWS\System32\Notepad2.exe %1" /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>notepad2 edit</Description>

<Order>27</Order>

<CommandLine>cmd /c reg add "HKLM\SOFTWARE\Classes\logfile\Shell\Edit\command" /v "" /t REG_SZ /d "C:\WINDOWS\System32\Notepad2.exe %1" /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>notification off</Description>

<Order>28</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Policies\Microsoft\Windows\Explorer" /v DisableNotificationCenter /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>iexplore dont ask for info retention</Description>

<Order>29</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Internet Explorer\IntelliForms" /v AskUser /t REG_DWORD /d 0 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>classic panel</Description>

<Order>30</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v ForceClassicControlPanel /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>explorer classi view</Description>

<Order>31</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ClassicViewState /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>explorer webview off</Description>

<Order>32</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v WebView /t REG_DWORD /d 0 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>hide icons</Description>

<Order>33</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideIcons /t REG_DWORD /d 0 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>show hidden files</Description>

<Order>34</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Hidden /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>show all icon taskbar</Description>

<Order>35</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarGlomming /t REG_DWORD /d 0 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>taskbar change size</Description>

<Order>36</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarSizeMove /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>task bar dont group icons</Description>

<Order>37</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarGlomLevel /t REG_DWORD /d 2 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>explorer shell state</Description>

<Order>38</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer" /v ShellState /t REG_BINARY /d 2400000033080000000000000000000000000000010000000d0000000000000000000000 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>no icone on shortcut maybe</Description>

<Order>39</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer" /v IconUnderline /t REG_BINARY /d 030000 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>dont hide right side icons</Description>

<Order>40</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer" /v EnableAutoTray /t REG_DWORD /d 0 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>Control Panel View</Description>

<Order>41</Order>

<CommandLine>reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" /v StartupPage /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>Control Panel Icon Size type</Description>

<Order>42</Order>

<CommandLine>reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" /v AllItemsIconView /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>explorer dont hide file extensions</Description>

<Order>43</Order>

<CommandLine>cmd /c reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>explorer classic view state</Description>

<Order>44</Order>

<CommandLine>cmd /c reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ClassicViewState /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>media player privacy statement</Description>

<Order>45</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\MediaPlayer\Preferences" /v AcceptedPrivacyStatement /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>media player</Description>

<Order>46</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\MediaPlayer\Preferences" /v FirstRun /t REG_DWORD /d 0 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>iexplore runonce done</Description>

<Order>47</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Internet Explorer\Main" /v RunOnceHasShown /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>iexplore runonce done</Description>

<Order>48</Order>

<CommandLine>cmd /c reg add "HKCU\Software\Microsoft\Internet Explorer\Main" /v RunOnceComplete /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>screenhunter</Description>

<Order>49</Order>

<CommandLine>msiexec /i c:\_appsall\screenhunterfree_prt_scr\setupscreenhunterfree.msi /quiet</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>klite and media classic player any version</Description>

<Order>50</Order>

<CommandLine>cmd /c c:\_appsall\video_codecs_convert\commandline.bat</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>java 23 and 64 any version</Description>

<Order>51</Order>

<CommandLine>cmd /c c:\_appsall\java_sun\commandline.bat</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>skype</Description>

<Order>52</Order>

<CommandLine>cmd /c c:\_appsall\skype\Skype_silent.exe</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>office 2013</Description>

<Order>53</Order>

<CommandLine>c:\_appsmaison\microsoft_office_2013_64_fra_files\setup.exe /adminfile office2013unattend.MSP</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>flash player</Description>

<Order>54</Order>

<CommandLine>msiexec.exe /i "C:\_appsall\flashplayer\install_flash_player_20_active_x.msi" /qn</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>flash player plugin</Description>

<Order>55</Order>

<CommandLine>msiexec.exe /i "C:\_appsall\flashplayer\install_flash_player_20_plugin.msi" /qn</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>administrateur account not expire after 3 months</Description>

<Order>56</Order>

<CommandLine>cmd.exe /c wmic useraccount where "name='administrateur'" set PasswordExpires=FALSE</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>utilisateur account not expire after 3 months</Description>

<Order>57</Order>

<CommandLine>cmd.exe /c wmic useraccount where "name='utilisateur'" set PasswordExpires=FALSE</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>install firefox</Description>

<Order>58</Order>

<CommandLine>cmd.exe /c "c:\_appsall\firefox\Firefox Setup 43.0.2.exe" -ms</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>mysql odbc connector 32</Description>

<Order>59</Order>

<CommandLine>msiexec /i c:\_appsall\MysqlOdbcConnector\mysql-connector-odbc-5.3.4-win32.msi /quiet</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>mysql odbc connector 64</Description>

<Order>60</Order>

<CommandLine>msiexec /i c:\_appsall\MysqlOdbcConnector\mysql-connector-odbc-5.3.4-winx64.msi /quiet</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>acrobat reader eula accepted</Description>

<Order>61</Order>

<CommandLine>cmd /c reg add "HKCU\SOFTWARE\Adobe\Acrobat Reader\11.0\AdobeViewer" /v EULA /t REG_DWORD /d 1 /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>todo folder on desktop</Description>

<Order>62</Order>

<CommandLine>cmd /c mkdir "%USERPROFILE%\desktop\A Faire - ToDo\"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>activation office 2013 et win10</Description>

<Order>63</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\activate windows 10 and office 2013.lnk" /a:c /t:"C:\_appsmaison\microsoft_office_2013_64_fra_files\_activation_off2013_fra\KMSAuto Net 2014 v1.3.4 Portable\KMSAuto Net.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>avast registration</Description>

<Order>64</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\register avast antivirus free.lnk" /a:c /t:"C:\Program Files\AVAST Software\Avast\avastui.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>tweaks windows</Description>

<Order>65</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Tweaks (setup profile).lnk" /a:c /t:"c:\_appsall\_01_tweaks.reg"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>malwarebyte setup</Description>

<Order>66</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Malwarebyte Setup.lnk" /a:c /t:"c:\_appsall\malwarebyte\mbam-setup-2.2.1.1043.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>spyware blaster setup</Description>

<Order>67</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\spywareblaster54 setup.lnk" /a:c /t:"c:\_appsall\spywareblaster\spywareblastersetup54.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>virtual drive setup</Description>

<Order>68</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\virtualclonedrive setup.lnk" /a:c /t:"c:\_appsall\virtualclonedrive\SetupVirtualCloneDrive5470.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>imgburn graveur program setup</Description>

<Order>69</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\imageburn graveur dvd setup.lnk" /a:c /t:"c:\_appsall\imageburn\SetupImgBurn_2.5.7.0.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>verification montage poste maison</Description>

<Order>70</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\verification_montage_poste_maison.lnk" /a:c /t:"c:\_util\installation\verification_montage_poste_maison.vbs"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>steam setup</Description>

<Order>71</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Steam for games.lnk" /a:c /t:"c:\_appsmaison\steam_installer\SteamSetup.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>torrent setup</Description>

<Order>72</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Qbitorrent for torrents.lnk" /a:c /t:"c:\_appsmaison\torrent_client\qbittorrent_3.3.10_setup.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>opera web browser setup</Description>

<Order>73</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Opera internet browser for 3d flash games.lnk" /a:c /t:"c:\_appsall\opera\Opera_42.0.2393.94_Setup.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>powerdvd setup</Description>

<Order>74</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\powerDVD for bluerays movies.lnk" /a:c /t:"c:\_appsmaison\powerdvd\Setup.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>teamviewer setup</Description>

<Order>75</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Teamviewer pour controle a distance.lnk" /a:c /t:"c:\_util\teamviewer\TeamViewer_Setup_fr-aiiz.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>power always on</Description>

<Order>76</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Power management jamaisoff run as admin.lnk" /a:c /t:"c:\_appsall\power.bat"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>vision viewer</Description>

<Order>77</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Visio viewer.lnk" /a:c /t:"c:\_appsall\visio_viewer\vsdviewer.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>video drivers intel</Description>

<Order>78</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Video driver intel.lnk" /a:c /t:"c:\_drivers_manual\video\win64_154510.4542.exe</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>video drivers nvidia</Description>

<Order>79</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Video driver Nvidia.lnk" /a:c /t:"c:\_drivers_manual\video\"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>amd radeon drivers</Description>

<Order>80</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Video driver AMD.lnk" /a:c /t:"c:\_drivers_manual\video\non-whql-win10-64bit-radeon-software-crimson-relive-16.12.2-dec19.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>power 2 hours</Description>

<Order>81</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\Power management 2 hours run as admin.lnk" /a:c /t:"c:\_appsall\power_2hours.bat"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>vlc video player</Description>

<Order>82</Order>

<CommandLine>cmd /c c:\_util\shortcut\Shortcut.exe /f:"%USERPROFILE%\Desktop\A Faire - ToDo\VLC video player 2016-12-31.lnk" /a:c /t:"c:\_appsall\video_vlc_player\vlc-2.2.4-win32.exe"</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>execute command after first reboot</Description>

<Order>83</Order>

<CommandLine>reg add HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v NewSetupScript /t Reg_SZ /d "c:\_updates\phase103.bat" /f</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>


-<SynchronousCommand wcm:action="add">

<Description>restart computer</Description>

<Order>84</Order>

<CommandLine>C:\Windows\System32\shutdown.exe /r /t 120</CommandLine>

<RequiresUserInput>false</RequiresUserInput>

</SynchronousCommand>

</FirstLogonCommands>

<TimeZone>Eastern Standard Time</TimeZone>

</component>

</settings>

</unattend>

Wednesday, December 7, 2016

ribbon generation in excel



Hello,

I wanted to generate a nice ribbon in excel with just VBA.

I like jagged / nested arrays.

Si here is my code to generate a ribbon in excel in vba:

It generate only one tab of a personalized ribbon called "Tables et dessins"
This tab contain id, name and groups (array)
These groups contains id, name and buttons (array)
These buttons contain id, label, on action (sub to execute when pressed), color (or image)

After executing the sub LoadCustRibbon2, you must restart excel for the ribbon to appear cause excel need to load the file.


--------------------- code excel 2010 or 2013 VBA 64 bits ----------------------

'=== ajout boutons
Sub LoadCustRibbon2()
    'http://stackoverflow.com/questions/8850836/how-to-add-a-custom-ribbon-tab-using-vba
 
    Dim hFile As Long
    Dim path As String, fileName As String, ribbonXML As String, user As String
 
    '=== location of the custom ribbon file in the user profile
    hFile = FreeFile
    user = Environ("Username")
    path = "C:\Users\" & user & "\AppData\Local\Microsoft\Office\"
    fileName = "Excel.officeUI"
 
    '=== id, label, on action, color
    buttons0000 = Array("rearrangetable", "Ajuster la table sur cette feuille", "autofit_table_data", "AppointmentColor2")
 
    '=== id, label
    groups00 = Array("Tables", "Tables", buttons0000)
 
    '=== id, label, on action, color
    buttons0100 = Array("addthistodrawing", "Ajouter la selection a la feuille Donnees_Dessin", "add_line_in_drawings", "AppointmentColor3")
    buttons0101 = Array("drawgeomaticgrid", "Dessiner sur la feuille Dessin les donnees dans Donnees_Dessin", "geo_grid_generation", "AppointmentColor4")
     
    '=== id, label
    groups01 = Array("Dessin", "Dessin", buttons0100, buttons0101)
 
    '=== id, label, on action, color
    buttons0200 = Array("generatesheets", "Genere feuille pour chaque ligne avec hyperlien", "sheet_generation", "AppointmentColor5")
 
    groups02 = Array("Feuilles", "Feuilles", buttons0200)
 
    '=== id, label
    tabs01 = Array("TablesandDrawing", "Tables et Dessins", groups00, groups01, groups02)
 
    '=== data
 
    ribbonXML = "" & vbNewLine
    ribbonXML = ribbonXML + "  " & vbNewLine
    ribbonXML = ribbonXML + "    " & vbNewLine
    ribbonXML = ribbonXML + "    " & vbNewLine

    ribbonXML = ribbonXML + "      " & vbNewLine
 
    For grocnt01 = 2 To UBound(tabs01) '=== elements 2 and more are arrays
        group01 = tabs01(grocnt01)
        ribbonXML = ribbonXML + "                ribbonXML = ribbonXML + "label='" & group01(1) & "' autoScale='true'>" & vbNewLine
     
        For butcnt01 = 2 To UBound(group01) '=== elements 2 and more are arrays
            button01 = group01(butcnt01)
            ribbonXML = ribbonXML + "                      ribbonXML = ribbonXML + "label='" & button01(1) & "' " & vbNewLine
            ribbonXML = ribbonXML + "imageMso='" & button01(3) & "'      onAction='" & button01(2) & "'/>" & vbNewLine
        Next 'butcnt01
        ribbonXML = ribbonXML + "        
" & vbNewLine
     
    Next 'grocnt01
    ribbonXML = ribbonXML + "    
" & vbNewLine 
    ribbonXML = ribbonXML + "  
" & vbNewLine    ribbonXML = ribbonXML + "
" & vbNewLine    ribbonXML = ribbonXML + "

    ribbonXML = Replace(ribbonXML, """", "")
 
    test = 0
    If test = 0 Then
        Open path & fileName For Output Access Write As hFile
        Print #hFile, ribbonXML
        Close hFile
    Else
        MsgBox (ribbonXML)
    End If
 
End Sub