Re: [WiX-users] seeing if a MSI is running using mutex... [P]

2015-01-28 Thread Phil Wilson
I believe so, yes.
---
Phil Wilson


On Wed, Jan 28, 2015 at 7:22 AM, Steven Ogilvie
steven.ogil...@titus.com wrote:
 Classification: Public
 So I presume a WAIT_ABANDONED means that a MSI is running?

 -Original Message-
 From: Phil Wilson [mailto:phildgwil...@gmail.com]
 Sent: January-27-15 3:49 PM
 To: General discussion about the WiX toolset.
 Subject: Re: [WiX-users] seeing if a MSI is running using mutex... [P]

 Now I look closer, I think you're missing something. CreateMute() by itself 
 isn't sufficient. You have to attempt to get it. The code I've used also has 
 a WaitForSingleObject to try to own the mutex:

 hMutex = CreateMutex(sa, FALSE, TEXT(Global\_MSIExecute)); .

 dwError = WaitForSingleObject(hMutex, INFINITE); if (WAIT_OBJECT_0 == 
 dwError) { // You have the mutex therefore MSI isn't installing anything }
 ---
 Phil Wilson


 On Tue, Jan 27, 2015 at 10:56 AM, Steven Ogilvie steven.ogil...@titus.com 
 wrote:
 Classification: Public
 There was code from NetFxChainer.cpp (CreateNetFxChainer):
 hr = StrAllocFormatted(sczName, L%ls_mutex, wzEventName);
 ExitOnFailure(hr, failed to allocate memory for mutex name);

 // Create the mutex, we initially own
 pChainer-hMutex = ::CreateMutex(NULL, TRUE, sczName);

 so I was trying that...

 it seems nothing is working... I have a MSI running and installing,
 another MSI pops up an error message that another MSI is running but
 my code isn't working, it isn't getting ERROR_ALREADY_EXISTS

 steve

 -Original Message-
 From: Phil Wilson [mailto:phildgwil...@gmail.com]
 Sent: January-27-15 1:25 PM
 To: General discussion about the WiX toolset.
 Subject: Re: [WiX-users] seeing if a MSI is running using mutex...

 I'll put it this way: I don't understand why you're not passing the string 
 LPCWSTR sczMutexName = LGlobal\\_MSIExecute; into CreateMutex().  Why the 
 StrAllocFormatted call?

 Also it's only locked during the execute sequence, and I don't know how 
 you're testing it.

 ---
 Phil Wilson


 On Tue, Jan 27, 2015 at 10:08 AM, StevenOgilvie sogil...@msn.com wrote:
 What is the actual MSI mutex?

 Thanks

 Steve

 From: Phil Wilson [via Windows Installer XML (WiX) toolset]
 Sent: Tuesday, January 27, 2015 12:59
 To: StevenOgilvie
 Subject: Re: seeing if a MSI is running using mutex...




 It appears that your CreateMutex isn't passing in the actual MSI
 mutex in sczMutexName .
 ---
 Phil Wilson


 On Tue, Jan 27, 2015 at 7:51 AM, StevenOgilvie sogil...@msn.com wrote:
 Hi all,

 Trying to create a method to detect if ANY MSI is running and if so
 halt bootstrapper...
 I am doing this in C++

 I get a successful mutex, but it always returns ERROR_SUCCESS, what
 am I doing wrong?
 thanks
 Steve


 HANDLE ghMutex = NULL;
 LPCWSTR sczVerifyMSIRunningVariableSet = L0; LPWSTR
 sczVerifyMSIRunningVariable = NULL; LPWSTR
 sczUnformattedVerifyMSIRunningVariable = NULL; LPCWSTR sczMutexName
 = LGlobal\\_MSIExecute; LPWSTR sczName = NULL; BOOL MutexExist =
 FALSE;

 // get the bootstrapper variable to change hr =
 BalGetStringVariable(WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING,
 sczUnformattedVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to get MSI running variable:
 %ls, WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING);
 hr = BalFormatString(sczUnformattedVerifyMSIRunningVariable,
 sczVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to format get MSI running variable:
 %ls, sczUnformattedVerifyMSIRunningVariable);
 hr = StrAllocFormatted(sczName, L%ls, sczMutexName);
 ::MessageBoxW(m_hWnd, (LPCWSTR)sczName,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 // check to see if any MSI is running
 ghMutex = ::CreateMutex(
 NULL,   // default security attributes
 FALSE,  // initially not owned
 sczName);   // product name

 if (ghMutex != NULL)
 {
 ::MessageBoxW(m_hWnd, LghMutex was not null,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 switch (GetLastError())
 {
 case ERROR_SUCCESS:
 // Mutex created successfully. There is no
 instance running
 ::MessageBoxW(m_hWnd, LghMutex: Mutex created
 successfully. There is no instance running FALSE,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 case ERROR_ALREADY_EXISTS:
 // Mutex already exists so there is a running instance
 ::MessageBoxW(m_hWnd, LghMutex: Mutex already
 exists so there is a running instance TRUE,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = TRUE;
 break;
 default:
 // Failed to create Mutex by unknown reason

Re: [WiX-users] seeing if a MSI is running using mutex... [P]

2015-01-28 Thread Steven Ogilvie
Classification: Public
So I presume a WAIT_ABANDONED means that a MSI is running?

-Original Message-
From: Phil Wilson [mailto:phildgwil...@gmail.com]
Sent: January-27-15 3:49 PM
To: General discussion about the WiX toolset.
Subject: Re: [WiX-users] seeing if a MSI is running using mutex... [P]

Now I look closer, I think you're missing something. CreateMute() by itself 
isn't sufficient. You have to attempt to get it. The code I've used also has a 
WaitForSingleObject to try to own the mutex:

hMutex = CreateMutex(sa, FALSE, TEXT(Global\_MSIExecute)); .

dwError = WaitForSingleObject(hMutex, INFINITE); if (WAIT_OBJECT_0 == dwError) 
{ // You have the mutex therefore MSI isn't installing anything }
---
Phil Wilson


On Tue, Jan 27, 2015 at 10:56 AM, Steven Ogilvie steven.ogil...@titus.com 
wrote:
 Classification: Public
 There was code from NetFxChainer.cpp (CreateNetFxChainer):
 hr = StrAllocFormatted(sczName, L%ls_mutex, wzEventName);
 ExitOnFailure(hr, failed to allocate memory for mutex name);

 // Create the mutex, we initially own
 pChainer-hMutex = ::CreateMutex(NULL, TRUE, sczName);

 so I was trying that...

 it seems nothing is working... I have a MSI running and installing, 
 another MSI pops up an error message that another MSI is running but 
 my code isn't working, it isn't getting ERROR_ALREADY_EXISTS

 steve

 -Original Message-
 From: Phil Wilson [mailto:phildgwil...@gmail.com]
 Sent: January-27-15 1:25 PM
 To: General discussion about the WiX toolset.
 Subject: Re: [WiX-users] seeing if a MSI is running using mutex...

 I'll put it this way: I don't understand why you're not passing the string 
 LPCWSTR sczMutexName = LGlobal\\_MSIExecute; into CreateMutex().  Why the 
 StrAllocFormatted call?

 Also it's only locked during the execute sequence, and I don't know how 
 you're testing it.

 ---
 Phil Wilson


 On Tue, Jan 27, 2015 at 10:08 AM, StevenOgilvie sogil...@msn.com wrote:
 What is the actual MSI mutex?

 Thanks

 Steve

 From: Phil Wilson [via Windows Installer XML (WiX) toolset]
 Sent: Tuesday, January 27, 2015 12:59
 To: StevenOgilvie
 Subject: Re: seeing if a MSI is running using mutex...




 It appears that your CreateMutex isn't passing in the actual MSI 
 mutex in sczMutexName .
 ---
 Phil Wilson


 On Tue, Jan 27, 2015 at 7:51 AM, StevenOgilvie sogil...@msn.com wrote:
 Hi all,

 Trying to create a method to detect if ANY MSI is running and if so 
 halt bootstrapper...
 I am doing this in C++

 I get a successful mutex, but it always returns ERROR_SUCCESS, what 
 am I doing wrong?
 thanks
 Steve


 HANDLE ghMutex = NULL;
 LPCWSTR sczVerifyMSIRunningVariableSet = L0; LPWSTR 
 sczVerifyMSIRunningVariable = NULL; LPWSTR 
 sczUnformattedVerifyMSIRunningVariable = NULL; LPCWSTR sczMutexName 
 = LGlobal\\_MSIExecute; LPWSTR sczName = NULL; BOOL MutexExist = 
 FALSE;

 // get the bootstrapper variable to change hr = 
 BalGetStringVariable(WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING,
 sczUnformattedVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to get MSI running variable:
 %ls, WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING);
 hr = BalFormatString(sczUnformattedVerifyMSIRunningVariable,
 sczVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to format get MSI running variable:
 %ls, sczUnformattedVerifyMSIRunningVariable);
 hr = StrAllocFormatted(sczName, L%ls, sczMutexName);
 ::MessageBoxW(m_hWnd, (LPCWSTR)sczName, 
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 // check to see if any MSI is running
 ghMutex = ::CreateMutex(
 NULL,   // default security attributes
 FALSE,  // initially not owned
 sczName);   // product name

 if (ghMutex != NULL)
 {
 ::MessageBoxW(m_hWnd, LghMutex was not null, 
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 switch (GetLastError())
 {
 case ERROR_SUCCESS:
 // Mutex created successfully. There is no 
 instance running
 ::MessageBoxW(m_hWnd, LghMutex: Mutex created 
 successfully. There is no instance running FALSE, 
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 case ERROR_ALREADY_EXISTS:
 // Mutex already exists so there is a running instance
 ::MessageBoxW(m_hWnd, LghMutex: Mutex already 
 exists so there is a running instance TRUE, 
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = TRUE;
 break;
 default:
 // Failed to create Mutex by unknown reason
 ::MessageBoxW(m_hWnd, LghMutex: Failed to 
 create Mutex by unknown reason FALSE, 
 (LPCWSTR)m_pTheme-sczCaption, MB_OK

Re: [WiX-users] seeing if a MSI is running using mutex...

2015-01-27 Thread Phil Wilson
I'll put it this way: I don't understand why you're not passing the
string LPCWSTR sczMutexName = LGlobal\\_MSIExecute; into
CreateMutex().  Why the StrAllocFormatted call?

Also it's only locked during the execute sequence, and I don't know
how you're testing it.

---
Phil Wilson


On Tue, Jan 27, 2015 at 10:08 AM, StevenOgilvie sogil...@msn.com wrote:
 What is the actual MSI mutex?

 Thanks

 Steve

 From: Phil Wilson [via Windows Installer XML (WiX) toolset]
 Sent: Tuesday, January 27, 2015 12:59
 To: StevenOgilvie
 Subject: Re: seeing if a MSI is running using mutex...




 It appears that your CreateMutex isn't passing in the actual MSI mutex
 in sczMutexName .
 ---
 Phil Wilson


 On Tue, Jan 27, 2015 at 7:51 AM, StevenOgilvie sogil...@msn.com wrote:
 Hi all,

 Trying to create a method to detect if ANY MSI is running and if so halt
 bootstrapper...
 I am doing this in C++

 I get a successful mutex, but it always returns ERROR_SUCCESS, what am I
 doing wrong?
 thanks
 Steve


 HANDLE ghMutex = NULL;
 LPCWSTR sczVerifyMSIRunningVariableSet = L0;
 LPWSTR sczVerifyMSIRunningVariable = NULL;
 LPWSTR sczUnformattedVerifyMSIRunningVariable = NULL;
 LPCWSTR sczMutexName = LGlobal\\_MSIExecute;
 LPWSTR sczName = NULL;
 BOOL MutexExist = FALSE;

 // get the bootstrapper variable to change
 hr = BalGetStringVariable(WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING,
 sczUnformattedVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to get MSI running variable: %ls,
 WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING);
 hr = BalFormatString(sczUnformattedVerifyMSIRunningVariable,
 sczVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to format get MSI running variable:
 %ls, sczUnformattedVerifyMSIRunningVariable);
 hr = StrAllocFormatted(sczName, L%ls, sczMutexName);
 ::MessageBoxW(m_hWnd, (LPCWSTR)sczName,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 // check to see if any MSI is running
 ghMutex = ::CreateMutex(
 NULL,   // default security attributes
 FALSE,  // initially not owned
 sczName);   // product name

 if (ghMutex != NULL)
 {
 ::MessageBoxW(m_hWnd, LghMutex was not null,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 switch (GetLastError())
 {
 case ERROR_SUCCESS:
 // Mutex created successfully. There is no instance
 running
 ::MessageBoxW(m_hWnd, LghMutex: Mutex created
 successfully. There is no instance running FALSE,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 case ERROR_ALREADY_EXISTS:
 // Mutex already exists so there is a running instance
 ::MessageBoxW(m_hWnd, LghMutex: Mutex already exists so
 there is a running instance TRUE, (LPCWSTR)m_pTheme-sczCaption, MB_OK |
 MB_ICONWARNING);
 MutexExist = TRUE;
 break;
 default:
 // Failed to create Mutex by unknown reason
 ::MessageBoxW(m_hWnd, LghMutex: Failed to create Mutex
 by unknown reason FALSE, (LPCWSTR)m_pTheme-sczCaption, MB_OK |
 MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 }
 }

 if (MutexExist)
 {
 sczVerifyMSIRunningVariableSet = L1;
 }

 // a MSI is installing
 hr =
 m_pEngine-SetVariableString(LPCWSTR(sczVerifyMSIRunningVariable),
 sczVerifyMSIRunningVariableSet);



 --
 View this message in context: 
 http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/seeing-if-a-MSI-is-running-using-mutex-tp7599025.html
 Sent from the wix-users mailing list archive at Nabble.com.

 --
 Dive into the World of Parallel Programming. The Go Parallel Website,
 sponsored by Intel and developed in partnership with Slashdot Media, is your
 hub for all things parallel software development, from weekly thought
 leadership blogs to news, videos, case studies, tutorials and more. Take a
 look and join the conversation now. http://goparallel.sourceforge.net/
 ___
 WiX-users mailing list
 WiX-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wix-users

 --
 Dive into the World of Parallel Programming. The Go Parallel Website,
 sponsored by Intel and developed in partnership with Slashdot Media, is your
 hub for all things parallel software development, from weekly thought
 leadership blogs to news, videos, case studies, tutorials and more. Take a
 look and join the conversation now. http://goparallel.sourceforge.net/
 

Re: [WiX-users] seeing if a MSI is running using mutex...

2015-01-27 Thread StevenOgilvie
What is the actual MSI mutex?

Thanks

Steve

From: Phil Wilson [via Windows Installer XML (WiX) toolset]
Sent: Tuesday, January 27, 2015 12:59
To: StevenOgilvie
Subject: Re: seeing if a MSI is running using mutex...




It appears that your CreateMutex isn't passing in the actual MSI mutex
in sczMutexName .
---
Phil Wilson


On Tue, Jan 27, 2015 at 7:51 AM, StevenOgilvie sogil...@msn.com wrote:
 Hi all,

 Trying to create a method to detect if ANY MSI is running and if so halt
 bootstrapper...
 I am doing this in C++

 I get a successful mutex, but it always returns ERROR_SUCCESS, what am I
 doing wrong?
 thanks
 Steve


 HANDLE ghMutex = NULL;
 LPCWSTR sczVerifyMSIRunningVariableSet = L0;
 LPWSTR sczVerifyMSIRunningVariable = NULL;
 LPWSTR sczUnformattedVerifyMSIRunningVariable = NULL;
 LPCWSTR sczMutexName = LGlobal\\_MSIExecute;
 LPWSTR sczName = NULL;
 BOOL MutexExist = FALSE;

 // get the bootstrapper variable to change
 hr = BalGetStringVariable(WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING,
 sczUnformattedVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to get MSI running variable: %ls,
 WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING);
 hr = BalFormatString(sczUnformattedVerifyMSIRunningVariable,
 sczVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to format get MSI running variable:
 %ls, sczUnformattedVerifyMSIRunningVariable);
 hr = StrAllocFormatted(sczName, L%ls, sczMutexName);
 ::MessageBoxW(m_hWnd, (LPCWSTR)sczName,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 // check to see if any MSI is running
 ghMutex = ::CreateMutex(
 NULL,   // default security attributes
 FALSE,  // initially not owned
 sczName);   // product name

 if (ghMutex != NULL)
 {
 ::MessageBoxW(m_hWnd, LghMutex was not null,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 switch (GetLastError())
 {
 case ERROR_SUCCESS:
 // Mutex created successfully. There is no instance
 running
 ::MessageBoxW(m_hWnd, LghMutex: Mutex created
 successfully. There is no instance running FALSE,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 case ERROR_ALREADY_EXISTS:
 // Mutex already exists so there is a running instance
 ::MessageBoxW(m_hWnd, LghMutex: Mutex already exists so
 there is a running instance TRUE, (LPCWSTR)m_pTheme-sczCaption, MB_OK |
 MB_ICONWARNING);
 MutexExist = TRUE;
 break;
 default:
 // Failed to create Mutex by unknown reason
 ::MessageBoxW(m_hWnd, LghMutex: Failed to create Mutex
 by unknown reason FALSE, (LPCWSTR)m_pTheme-sczCaption, MB_OK |
 MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 }
 }

 if (MutexExist)
 {
 sczVerifyMSIRunningVariableSet = L1;
 }

 // a MSI is installing
 hr =
 m_pEngine-SetVariableString(LPCWSTR(sczVerifyMSIRunningVariable),
 sczVerifyMSIRunningVariableSet);



 --
 View this message in context: 
 http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/seeing-if-a-MSI-is-running-using-mutex-tp7599025.html
 Sent from the wix-users mailing list archive at Nabble.com.

 --
 Dive into the World of Parallel Programming. The Go Parallel Website,
 sponsored by Intel and developed in partnership with Slashdot Media, is your
 hub for all things parallel software development, from weekly thought
 leadership blogs to news, videos, case studies, tutorials and more. Take a
 look and join the conversation now. http://goparallel.sourceforge.net/
 ___
 WiX-users mailing list
 WiX-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wix-users

--
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
___
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users




___
If you reply to this email, your message will be added to the discussion below:

Re: [WiX-users] seeing if a MSI is running using mutex...

2015-01-27 Thread Phil Wilson
The docs seem to indicate that it's still used, but they also suggest
querying the service status to see if it's accepting shutdown
commands.

https://msdn.microsoft.com/en-us/library/aa372909(v=vs.85).aspx
---
Phil Wilson


On Tue, Jan 27, 2015 at 9:56 AM, Rob Mensching r...@firegiant.com wrote:
 I could be wrong but I thought MSI stopped using the mutex a couple versions 
 ago.

 _
  Short replies here. Complete answers over there: http://www.firegiant.com/


 -Original Message-
 From: StevenOgilvie [mailto:sogil...@msn.com]
 Sent: Tuesday, January 27, 2015 7:51 AM
 To: wix-users@lists.sourceforge.net
 Subject: [WiX-users] seeing if a MSI is running using mutex...

 Hi all,

 Trying to create a method to detect if ANY MSI is running and if so halt 
 bootstrapper...
 I am doing this in C++

 I get a successful mutex, but it always returns ERROR_SUCCESS, what am I 
 doing wrong?
 thanks
 Steve


 HANDLE ghMutex = NULL;
 LPCWSTR sczVerifyMSIRunningVariableSet = L0;
 LPWSTR sczVerifyMSIRunningVariable = NULL;
 LPWSTR sczUnformattedVerifyMSIRunningVariable = NULL;
 LPCWSTR sczMutexName = LGlobal\\_MSIExecute;
 LPWSTR sczName = NULL;
 BOOL MutexExist = FALSE;

 // get the bootstrapper variable to change
 hr = BalGetStringVariable(WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING,
 sczUnformattedVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to get MSI running variable: %ls,
 WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING);
 hr = BalFormatString(sczUnformattedVerifyMSIRunningVariable,
 sczVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to format get MSI running variable:
 %ls, sczUnformattedVerifyMSIRunningVariable);
 hr = StrAllocFormatted(sczName, L%ls, sczMutexName);
 ::MessageBoxW(m_hWnd, (LPCWSTR)sczName,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 // check to see if any MSI is running
 ghMutex = ::CreateMutex(
 NULL,   // default security attributes
 FALSE,  // initially not owned
 sczName);   // product name

 if (ghMutex != NULL)
 {
 ::MessageBoxW(m_hWnd, LghMutex was not null,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 switch (GetLastError())
 {
 case ERROR_SUCCESS:
 // Mutex created successfully. There is no instance
 running
 ::MessageBoxW(m_hWnd, LghMutex: Mutex created
 successfully. There is no instance running FALSE,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 case ERROR_ALREADY_EXISTS:
 // Mutex already exists so there is a running instance
 ::MessageBoxW(m_hWnd, LghMutex: Mutex already exists so
 there is a running instance TRUE, (LPCWSTR)m_pTheme-sczCaption, MB_OK |
 MB_ICONWARNING);
 MutexExist = TRUE;
 break;
 default:
 // Failed to create Mutex by unknown reason
 ::MessageBoxW(m_hWnd, LghMutex: Failed to create Mutex
 by unknown reason FALSE, (LPCWSTR)m_pTheme-sczCaption, MB_OK |
 MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 }
 }

 if (MutexExist)
 {
 sczVerifyMSIRunningVariableSet = L1;
 }

 // a MSI is installing
 hr =
 m_pEngine-SetVariableString(LPCWSTR(sczVerifyMSIRunningVariable),
 sczVerifyMSIRunningVariableSet);



 --
 View this message in context: 
 http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/seeing-if-a-MSI-is-running-using-mutex-tp7599025.html
 Sent from the wix-users mailing list archive at Nabble.com.

 --
 Dive into the World of Parallel Programming. The Go Parallel Website,
 sponsored by Intel and developed in partnership with Slashdot Media, is your
 hub for all things parallel software development, from weekly thought
 leadership blogs to news, videos, case studies, tutorials and more. Take a
 look and join the conversation now. http://goparallel.sourceforge.net/
 ___
 WiX-users mailing list
 WiX-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wix-users

 --
 Dive into the World of Parallel Programming. The Go Parallel Website,
 sponsored by Intel and developed in partnership with Slashdot Media, is your
 hub for all things parallel software development, from weekly thought
 leadership blogs to news, videos, case studies, tutorials and more. Take a
 look and join the conversation now. http://goparallel.sourceforge.net/
 

Re: [WiX-users] seeing if a MSI is running using mutex... [P]

2015-01-27 Thread Steven Ogilvie
Classification: Public
There was code from NetFxChainer.cpp (CreateNetFxChainer):
hr = StrAllocFormatted(sczName, L%ls_mutex, wzEventName);
ExitOnFailure(hr, failed to allocate memory for mutex name);

// Create the mutex, we initially own
pChainer-hMutex = ::CreateMutex(NULL, TRUE, sczName);

so I was trying that...

it seems nothing is working... I have a MSI running and installing, another MSI 
pops up an error message that another MSI is running but my code isn't working, 
it isn't getting ERROR_ALREADY_EXISTS

steve

-Original Message-
From: Phil Wilson [mailto:phildgwil...@gmail.com]
Sent: January-27-15 1:25 PM
To: General discussion about the WiX toolset.
Subject: Re: [WiX-users] seeing if a MSI is running using mutex...

I'll put it this way: I don't understand why you're not passing the string 
LPCWSTR sczMutexName = LGlobal\\_MSIExecute; into CreateMutex().  Why the 
StrAllocFormatted call?

Also it's only locked during the execute sequence, and I don't know how you're 
testing it.

---
Phil Wilson


On Tue, Jan 27, 2015 at 10:08 AM, StevenOgilvie sogil...@msn.com wrote:
 What is the actual MSI mutex?

 Thanks

 Steve

 From: Phil Wilson [via Windows Installer XML (WiX) toolset]
 Sent: Tuesday, January 27, 2015 12:59
 To: StevenOgilvie
 Subject: Re: seeing if a MSI is running using mutex...




 It appears that your CreateMutex isn't passing in the actual MSI mutex 
 in sczMutexName .
 ---
 Phil Wilson


 On Tue, Jan 27, 2015 at 7:51 AM, StevenOgilvie sogil...@msn.com wrote:
 Hi all,

 Trying to create a method to detect if ANY MSI is running and if so 
 halt bootstrapper...
 I am doing this in C++

 I get a successful mutex, but it always returns ERROR_SUCCESS, what 
 am I doing wrong?
 thanks
 Steve


 HANDLE ghMutex = NULL;
 LPCWSTR sczVerifyMSIRunningVariableSet = L0; LPWSTR 
 sczVerifyMSIRunningVariable = NULL; LPWSTR 
 sczUnformattedVerifyMSIRunningVariable = NULL; LPCWSTR sczMutexName = 
 LGlobal\\_MSIExecute; LPWSTR sczName = NULL; BOOL MutexExist = 
 FALSE;

 // get the bootstrapper variable to change hr = 
 BalGetStringVariable(WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING,
 sczUnformattedVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to get MSI running variable: 
 %ls, WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING);
 hr = BalFormatString(sczUnformattedVerifyMSIRunningVariable,
 sczVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to format get MSI running variable:
 %ls, sczUnformattedVerifyMSIRunningVariable);
 hr = StrAllocFormatted(sczName, L%ls, sczMutexName);
 ::MessageBoxW(m_hWnd, (LPCWSTR)sczName, 
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 // check to see if any MSI is running
 ghMutex = ::CreateMutex(
 NULL,   // default security attributes
 FALSE,  // initially not owned
 sczName);   // product name

 if (ghMutex != NULL)
 {
 ::MessageBoxW(m_hWnd, LghMutex was not null, 
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 switch (GetLastError())
 {
 case ERROR_SUCCESS:
 // Mutex created successfully. There is no 
 instance running
 ::MessageBoxW(m_hWnd, LghMutex: Mutex created 
 successfully. There is no instance running FALSE, 
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 case ERROR_ALREADY_EXISTS:
 // Mutex already exists so there is a running instance
 ::MessageBoxW(m_hWnd, LghMutex: Mutex already 
 exists so there is a running instance TRUE, 
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = TRUE;
 break;
 default:
 // Failed to create Mutex by unknown reason
 ::MessageBoxW(m_hWnd, LghMutex: Failed to create 
 Mutex by unknown reason FALSE, (LPCWSTR)m_pTheme-sczCaption, MB_OK
 | MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 }
 }

 if (MutexExist)
 {
 sczVerifyMSIRunningVariableSet = L1;
 }

 // a MSI is installing
 hr =
 m_pEngine-SetVariableString(LPCWSTR(sczVerifyMSIRunningVariable),
 sczVerifyMSIRunningVariableSet);




 
This message has been marked as Public by Steven Ogilvie on January-27-15 
1:56:22 PM.

The above classification labels were added to the message by TITUS Message 
Classification. 
For more information visit www.titus.com.

--
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from

Re: [WiX-users] seeing if a MSI is running using mutex... [P]

2015-01-27 Thread Phil Wilson
Now I look closer, I think you're missing something. CreateMute() by
itself isn't sufficient. You have to attempt to get it. The code I've
used also has a WaitForSingleObject to try to own the mutex:

hMutex = CreateMutex(sa, FALSE, TEXT(Global\_MSIExecute));
.

dwError = WaitForSingleObject(hMutex, INFINITE);
if (WAIT_OBJECT_0 == dwError)
{
// You have the mutex therefore MSI isn't installing anything
}
---
Phil Wilson


On Tue, Jan 27, 2015 at 10:56 AM, Steven Ogilvie
steven.ogil...@titus.com wrote:
 Classification: Public
 There was code from NetFxChainer.cpp (CreateNetFxChainer):
 hr = StrAllocFormatted(sczName, L%ls_mutex, wzEventName);
 ExitOnFailure(hr, failed to allocate memory for mutex name);

 // Create the mutex, we initially own
 pChainer-hMutex = ::CreateMutex(NULL, TRUE, sczName);

 so I was trying that...

 it seems nothing is working... I have a MSI running and installing, another 
 MSI pops up an error message that another MSI is running but my code isn't 
 working, it isn't getting ERROR_ALREADY_EXISTS

 steve

 -Original Message-
 From: Phil Wilson [mailto:phildgwil...@gmail.com]
 Sent: January-27-15 1:25 PM
 To: General discussion about the WiX toolset.
 Subject: Re: [WiX-users] seeing if a MSI is running using mutex...

 I'll put it this way: I don't understand why you're not passing the string 
 LPCWSTR sczMutexName = LGlobal\\_MSIExecute; into CreateMutex().  Why the 
 StrAllocFormatted call?

 Also it's only locked during the execute sequence, and I don't know how 
 you're testing it.

 ---
 Phil Wilson


 On Tue, Jan 27, 2015 at 10:08 AM, StevenOgilvie sogil...@msn.com wrote:
 What is the actual MSI mutex?

 Thanks

 Steve

 From: Phil Wilson [via Windows Installer XML (WiX) toolset]
 Sent: Tuesday, January 27, 2015 12:59
 To: StevenOgilvie
 Subject: Re: seeing if a MSI is running using mutex...




 It appears that your CreateMutex isn't passing in the actual MSI mutex
 in sczMutexName .
 ---
 Phil Wilson


 On Tue, Jan 27, 2015 at 7:51 AM, StevenOgilvie sogil...@msn.com wrote:
 Hi all,

 Trying to create a method to detect if ANY MSI is running and if so
 halt bootstrapper...
 I am doing this in C++

 I get a successful mutex, but it always returns ERROR_SUCCESS, what
 am I doing wrong?
 thanks
 Steve


 HANDLE ghMutex = NULL;
 LPCWSTR sczVerifyMSIRunningVariableSet = L0; LPWSTR
 sczVerifyMSIRunningVariable = NULL; LPWSTR
 sczUnformattedVerifyMSIRunningVariable = NULL; LPCWSTR sczMutexName =
 LGlobal\\_MSIExecute; LPWSTR sczName = NULL; BOOL MutexExist =
 FALSE;

 // get the bootstrapper variable to change hr =
 BalGetStringVariable(WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING,
 sczUnformattedVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to get MSI running variable:
 %ls, WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING);
 hr = BalFormatString(sczUnformattedVerifyMSIRunningVariable,
 sczVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to format get MSI running variable:
 %ls, sczUnformattedVerifyMSIRunningVariable);
 hr = StrAllocFormatted(sczName, L%ls, sczMutexName);
 ::MessageBoxW(m_hWnd, (LPCWSTR)sczName,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 // check to see if any MSI is running
 ghMutex = ::CreateMutex(
 NULL,   // default security attributes
 FALSE,  // initially not owned
 sczName);   // product name

 if (ghMutex != NULL)
 {
 ::MessageBoxW(m_hWnd, LghMutex was not null,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 switch (GetLastError())
 {
 case ERROR_SUCCESS:
 // Mutex created successfully. There is no
 instance running
 ::MessageBoxW(m_hWnd, LghMutex: Mutex created
 successfully. There is no instance running FALSE,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 case ERROR_ALREADY_EXISTS:
 // Mutex already exists so there is a running instance
 ::MessageBoxW(m_hWnd, LghMutex: Mutex already
 exists so there is a running instance TRUE,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = TRUE;
 break;
 default:
 // Failed to create Mutex by unknown reason
 ::MessageBoxW(m_hWnd, LghMutex: Failed to create
 Mutex by unknown reason FALSE, (LPCWSTR)m_pTheme-sczCaption, MB_OK
 | MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 }
 }

 if (MutexExist)
 {
 sczVerifyMSIRunningVariableSet = L1;
 }

 // a MSI is installing
 hr =
 m_pEngine-SetVariableString(LPCWSTR(sczVerifyMSIRunningVariable

Re: [WiX-users] seeing if a MSI is running using mutex...

2015-01-27 Thread Rob Mensching
I could be wrong but I thought MSI stopped using the mutex a couple versions 
ago.

_
 Short replies here. Complete answers over there: http://www.firegiant.com/


-Original Message-
From: StevenOgilvie [mailto:sogil...@msn.com] 
Sent: Tuesday, January 27, 2015 7:51 AM
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] seeing if a MSI is running using mutex...

Hi all,

Trying to create a method to detect if ANY MSI is running and if so halt 
bootstrapper...
I am doing this in C++

I get a successful mutex, but it always returns ERROR_SUCCESS, what am I doing 
wrong?
thanks
Steve


HANDLE ghMutex = NULL;
LPCWSTR sczVerifyMSIRunningVariableSet = L0;
LPWSTR sczVerifyMSIRunningVariable = NULL;
LPWSTR sczUnformattedVerifyMSIRunningVariable = NULL;
LPCWSTR sczMutexName = LGlobal\\_MSIExecute;
LPWSTR sczName = NULL;
BOOL MutexExist = FALSE;

// get the bootstrapper variable to change
hr = BalGetStringVariable(WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING,
sczUnformattedVerifyMSIRunningVariable);
BalExitOnFailure1(hr, Failed to get MSI running variable: %ls,
WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING);
hr = BalFormatString(sczUnformattedVerifyMSIRunningVariable,
sczVerifyMSIRunningVariable);
BalExitOnFailure1(hr, Failed to format get MSI running variable:
%ls, sczUnformattedVerifyMSIRunningVariable);
hr = StrAllocFormatted(sczName, L%ls, sczMutexName);
::MessageBoxW(m_hWnd, (LPCWSTR)sczName,
(LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

// check to see if any MSI is running
ghMutex = ::CreateMutex( 
NULL,   // default security attributes
FALSE,  // initially not owned
sczName);   // product name

if (ghMutex != NULL)
{
::MessageBoxW(m_hWnd, LghMutex was not null,
(LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

switch (GetLastError())
{
case ERROR_SUCCESS:
// Mutex created successfully. There is no instance
running
::MessageBoxW(m_hWnd, LghMutex: Mutex created
successfully. There is no instance running FALSE,
(LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
MutexExist = FALSE;
break;
case ERROR_ALREADY_EXISTS:
// Mutex already exists so there is a running instance
::MessageBoxW(m_hWnd, LghMutex: Mutex already exists so
there is a running instance TRUE, (LPCWSTR)m_pTheme-sczCaption, MB_OK |
MB_ICONWARNING);
MutexExist = TRUE;
break;
default:
// Failed to create Mutex by unknown reason
::MessageBoxW(m_hWnd, LghMutex: Failed to create Mutex
by unknown reason FALSE, (LPCWSTR)m_pTheme-sczCaption, MB_OK |
MB_ICONWARNING);
MutexExist = FALSE;
break;
}
}

if (MutexExist)
{
sczVerifyMSIRunningVariableSet = L1;
}

// a MSI is installing
hr =
m_pEngine-SetVariableString(LPCWSTR(sczVerifyMSIRunningVariable),
sczVerifyMSIRunningVariableSet);



--
View this message in context: 
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/seeing-if-a-MSI-is-running-using-mutex-tp7599025.html
Sent from the wix-users mailing list archive at Nabble.com.

--
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
___
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

--
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
___
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


Re: [WiX-users] seeing if a MSI is running using mutex...

2015-01-27 Thread Phil Wilson
It appears that your CreateMutex isn't passing in the actual MSI mutex
in sczMutexName .
---
Phil Wilson


On Tue, Jan 27, 2015 at 7:51 AM, StevenOgilvie sogil...@msn.com wrote:
 Hi all,

 Trying to create a method to detect if ANY MSI is running and if so halt
 bootstrapper...
 I am doing this in C++

 I get a successful mutex, but it always returns ERROR_SUCCESS, what am I
 doing wrong?
 thanks
 Steve


 HANDLE ghMutex = NULL;
 LPCWSTR sczVerifyMSIRunningVariableSet = L0;
 LPWSTR sczVerifyMSIRunningVariable = NULL;
 LPWSTR sczUnformattedVerifyMSIRunningVariable = NULL;
 LPCWSTR sczMutexName = LGlobal\\_MSIExecute;
 LPWSTR sczName = NULL;
 BOOL MutexExist = FALSE;

 // get the bootstrapper variable to change
 hr = BalGetStringVariable(WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING,
 sczUnformattedVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to get MSI running variable: %ls,
 WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING);
 hr = BalFormatString(sczUnformattedVerifyMSIRunningVariable,
 sczVerifyMSIRunningVariable);
 BalExitOnFailure1(hr, Failed to format get MSI running variable:
 %ls, sczUnformattedVerifyMSIRunningVariable);
 hr = StrAllocFormatted(sczName, L%ls, sczMutexName);
 ::MessageBoxW(m_hWnd, (LPCWSTR)sczName,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 // check to see if any MSI is running
 ghMutex = ::CreateMutex(
 NULL,   // default security attributes
 FALSE,  // initially not owned
 sczName);   // product name

 if (ghMutex != NULL)
 {
 ::MessageBoxW(m_hWnd, LghMutex was not null,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);

 switch (GetLastError())
 {
 case ERROR_SUCCESS:
 // Mutex created successfully. There is no instance
 running
 ::MessageBoxW(m_hWnd, LghMutex: Mutex created
 successfully. There is no instance running FALSE,
 (LPCWSTR)m_pTheme-sczCaption, MB_OK | MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 case ERROR_ALREADY_EXISTS:
 // Mutex already exists so there is a running instance
 ::MessageBoxW(m_hWnd, LghMutex: Mutex already exists so
 there is a running instance TRUE, (LPCWSTR)m_pTheme-sczCaption, MB_OK |
 MB_ICONWARNING);
 MutexExist = TRUE;
 break;
 default:
 // Failed to create Mutex by unknown reason
 ::MessageBoxW(m_hWnd, LghMutex: Failed to create Mutex
 by unknown reason FALSE, (LPCWSTR)m_pTheme-sczCaption, MB_OK |
 MB_ICONWARNING);
 MutexExist = FALSE;
 break;
 }
 }

 if (MutexExist)
 {
 sczVerifyMSIRunningVariableSet = L1;
 }

 // a MSI is installing
 hr =
 m_pEngine-SetVariableString(LPCWSTR(sczVerifyMSIRunningVariable),
 sczVerifyMSIRunningVariableSet);



 --
 View this message in context: 
 http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/seeing-if-a-MSI-is-running-using-mutex-tp7599025.html
 Sent from the wix-users mailing list archive at Nabble.com.

 --
 Dive into the World of Parallel Programming. The Go Parallel Website,
 sponsored by Intel and developed in partnership with Slashdot Media, is your
 hub for all things parallel software development, from weekly thought
 leadership blogs to news, videos, case studies, tutorials and more. Take a
 look and join the conversation now. http://goparallel.sourceforge.net/
 ___
 WiX-users mailing list
 WiX-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wix-users

--
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
___
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users