V tabeli ScheduledTask sem stolpec WorkingDir preimenoval v Directory_ ter popravil metodo CMSITSCAOpTaskCreate::SetFromRecord(), da zdaj določi delovni imenik s funkcijo MsiGetTargetPath(). Tako mora zdaj v stolpcu Directory_ pisati ključ imenika (v tabeli Directory) in ne več pot.

Verzijo sem nastavil na 1.0.1.
This commit is contained in:
Simon Rozman 2013-01-31 07:37:24 +00:00
parent 7dc1a6c2f6
commit 6105b60ac9
4 changed files with 62 additions and 9 deletions

View File

@ -72,7 +72,7 @@ UINT MSITSCA_API EvaluateScheduledTasks(MSIHANDLE hInstall)
PMSIHANDLE hViewST; PMSIHANDLE hViewST;
// Prepare a query to get a list/view of tasks. // Prepare a query to get a list/view of tasks.
uiResult = ::MsiDatabaseOpenView(hDatabase, _T("SELECT Task,DisplayName,Application,Parameters,WorkingDir,Flags,Priority,User,Password,Author,Description,IdleMin,IdleDeadline,MaxRuntime,Condition,Component_ FROM ScheduledTask"), &hViewST); uiResult = ::MsiDatabaseOpenView(hDatabase, _T("SELECT Task,DisplayName,Application,Parameters,Directory_,Flags,Priority,User,Password,Author,Description,IdleMin,IdleDeadline,MaxRuntime,Condition,Component_ FROM ScheduledTask"), &hViewST);
if (uiResult == ERROR_SUCCESS) { if (uiResult == ERROR_SUCCESS) {
// Execute query! // Execute query!
uiResult = ::MsiViewExecute(hViewST, NULL); uiResult = ::MsiViewExecute(hViewST, NULL);

View File

@ -6,14 +6,14 @@
// Constants // Constants
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
#define MSITSCA_VERSION 0x01000000 #define MSITSCA_VERSION 0x01000100
#define MSITSCA_VERSION_MAJ 1 #define MSITSCA_VERSION_MAJ 1
#define MSITSCA_VERSION_MIN 0 #define MSITSCA_VERSION_MIN 0
#define MSITSCA_VERSION_REV 0 #define MSITSCA_VERSION_REV 1
#define MSITSCA_VERSION_STR "1.0" #define MSITSCA_VERSION_STR "1.0.1"
#define MSITSCA_VERSION_INST "1.0.0.0" #define MSITSCA_VERSION_INST "1.0.1.0"
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -293,6 +293,56 @@ inline UINT MsiRecordFormatStringW(MSIHANDLE hInstall, MSIHANDLE hRecord, unsign
#endif // !UNICODE #endif // !UNICODE
inline UINT MsiGetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, CStringA &sValue)
{
DWORD dwSize = 0;
UINT uiResult;
// Query the final string length first.
uiResult = ::MsiGetTargetPathA(hInstall, szFolder, "", &dwSize);
if (uiResult == ERROR_MORE_DATA) {
// Prepare the buffer to format the string data into and read it.
LPSTR szBuffer = sValue.GetBuffer(dwSize++);
if (!szBuffer) return ERROR_OUTOFMEMORY;
uiResult = ::MsiGetTargetPathA(hInstall, szFolder, szBuffer, &dwSize);
sValue.ReleaseBuffer(uiResult == ERROR_SUCCESS ? dwSize : 0);
return uiResult;
} else if (uiResult == ERROR_SUCCESS) {
// The result is empty.
sValue.Empty();
return ERROR_SUCCESS;
} else {
// Return error code.
return uiResult;
}
}
inline UINT MsiGetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder, CStringW &sValue)
{
DWORD dwSize = 0;
UINT uiResult;
// Query the final string length first.
uiResult = ::MsiGetTargetPathW(hInstall, szFolder, L"", &dwSize);
if (uiResult == ERROR_MORE_DATA) {
// Prepare the buffer to format the string data into and read it.
LPWSTR szBuffer = sValue.GetBuffer(dwSize++);
if (!szBuffer) return ERROR_OUTOFMEMORY;
uiResult = ::MsiGetTargetPathW(hInstall, szFolder, szBuffer, &dwSize);
sValue.ReleaseBuffer(uiResult == ERROR_SUCCESS ? dwSize : 0);
return uiResult;
} else if (uiResult == ERROR_SUCCESS) {
// The result is empty.
sValue.Empty();
return ERROR_SUCCESS;
} else {
// Return error code.
return uiResult;
}
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Inline operators // Inline operators
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -589,6 +589,7 @@ UINT CMSITSCAOpTaskCreate::SetFromRecord(MSIHANDLE hInstall, MSIHANDLE hRecord)
{ {
UINT uiResult; UINT uiResult;
int iValue; int iValue;
CStringW sFolder;
uiResult = ::MsiRecordFormatStringW(hInstall, hRecord, 3, m_sApplicationName); uiResult = ::MsiRecordFormatStringW(hInstall, hRecord, 3, m_sApplicationName);
if (uiResult != ERROR_SUCCESS) return uiResult; if (uiResult != ERROR_SUCCESS) return uiResult;
@ -596,7 +597,9 @@ UINT CMSITSCAOpTaskCreate::SetFromRecord(MSIHANDLE hInstall, MSIHANDLE hRecord)
uiResult = ::MsiRecordFormatStringW(hInstall, hRecord, 4, m_sParameters); uiResult = ::MsiRecordFormatStringW(hInstall, hRecord, 4, m_sParameters);
if (uiResult != ERROR_SUCCESS) return uiResult; if (uiResult != ERROR_SUCCESS) return uiResult;
uiResult = ::MsiRecordFormatStringW(hInstall, hRecord, 5, m_sWorkingDirectory); uiResult = ::MsiRecordGetStringW(hRecord, 5, sFolder);
if (uiResult != ERROR_SUCCESS) return uiResult;
uiResult = ::MsiGetTargetPathW(hInstall, sFolder, m_sWorkingDirectory);
if (uiResult != ERROR_SUCCESS) return uiResult; if (uiResult != ERROR_SUCCESS) return uiResult;
if (!m_sWorkingDirectory.IsEmpty() && m_sWorkingDirectory.GetAt(m_sWorkingDirectory.GetLength() - 1) == L'\\') { if (!m_sWorkingDirectory.IsEmpty() && m_sWorkingDirectory.GetAt(m_sWorkingDirectory.GetLength() - 1) == L'\\') {
// Trim trailing backslash. // Trim trailing backslash.

View File

@ -25,7 +25,7 @@ ScheduledTask Task N Identifier Primary key, non-localized token.
ScheduledTask DisplayName N Formatted Task name. ScheduledTask DisplayName N Formatted Task name.
ScheduledTask Application N Formatted Task application name. ScheduledTask Application N Formatted Task application name.
ScheduledTask Parameters Y Formatted Task command line parameters. ScheduledTask Parameters Y Formatted Task command line parameters.
ScheduledTask WorkingDir N Formatted Task working directory. If the working directory is set to "", when the application is run, the current directory will be the directory in which the task scheduler service executable, Mstask.exe, resides. ScheduledTask Directory_ N Directory 1 Identifier Task working directory.
ScheduledTask Flags N DoubleInteger Task's flags to pass in IScheduledWorkItem::SetFlags() call. ScheduledTask Flags N DoubleInteger Task's flags to pass in IScheduledWorkItem::SetFlags() call.
ScheduledTask Priority N DoubleInteger 32;64;128;256;16384,32768 Task's priority to pass in ITask::SetPriority() call. ScheduledTask Priority N DoubleInteger 32;64;128;256;16384,32768 Task's priority to pass in ITask::SetPriority() call.
ScheduledTask User Y Formatted Account name to run task as. Use empty string for system account. ScheduledTask User Y Formatted Account name to run task as. Use empty string for system account.
@ -184,8 +184,8 @@ Vse :: "$(JEZIK).$(CFG).$(PLAT).ScheduledTask-1.idt"
"$(JEZIK).$(CFG).$(PLAT).ScheduledTask-1.idt" : "Makefile" "..\..\include\MSINast.mak" "$(JEZIK).$(CFG).$(PLAT).ScheduledTask-1.idt" : "Makefile" "..\..\include\MSINast.mak"
-if exist $@ del /f /q $@ -if exist $@ del /f /q $@
move /y << $@ > NUL move /y << $@ > NUL
Task DisplayName Application Parameters WorkingDir Flags Priority User Password Author Description IdleMin IdleDeadline MaxRuntime Condition Component_ Task DisplayName Application Parameters Directory_ Flags Priority User Password Author Description IdleMin IdleDeadline MaxRuntime Condition Component_
s$(MSI_TIP_ID) s255 s255 S255 s255 i4 i4 S255 S255 S255 S255 I2 I2 i4 S255 s$(MSI_TIP_ID) s$(MSI_TIP_ID) s255 s255 S255 s$(MSI_TIP_ID) i4 i4 S255 S255 S255 S255 I2 I2 i4 S255 s$(MSI_TIP_ID)
ScheduledTask Task ScheduledTask Task
<<NOKEEP <<NOKEEP