我正在尝试将我的本地(远程)数据库与服务器上的集中统一数据库(使用 Sybase 数据库)同步。同步必须在预定的时间发生,我正在使用“CreateProcessByUser”。为了启动同步过程,我使用的是 sybase 提供的 dbremote.exe。
构造的命令行参数为:
commandLine = dbremote.exe -l 512K -x -k -c "dsn=HOME* * ;uid=dba;pwd= ***;cs=none;DBKEY= ***" -os 10000000 -o "c:\data\test\dbremote.log" "c:\data\test"
BOOL startA_Process( HANDLE hToken, _TCHAR *commandLine, PROCESS_INFORMATION *pi, BOOL wait, _TCHAR *errBuf){
STARTUPINFO sStartupInfo;
DWORD dwExitCode;
DWORD dwStatus = 0;
DWORD dwCreationFlags = CREATE_NEW_CONSOLE;
int iResult;
BOOL bInheritHandles = FALSE;
LPCTSTR pszApplicationName = NULL;
LPCTSTR pszCurrentDirectory = NULL;
LPVOID pvEnvironment = NULL;
LPSECURITY_ATTRIBUTES psProcessAttributes = NULL;
LPSECURITY_ATTRIBUTES psThreadAttributes = NULL;
//
// Initilize STARTUPINFO structure
//
ZeroMemory( &sStartupInfo, sizeof( sStartupInfo ) );
sStartupInfo.cb = sizeof( sStartupInfo );
sStartupInfo.lpTitle = _T("AutoSychDBRemote");
sStartupInfo.lpDesktop = _T("winsta0\\default");
//
// Initilize PROCESS_INFORMATION structure
//
ZeroMemory( pi, sizeof( PROCESS_INFORMATION ) );
iResult = ::CreateProcessAsUser(
hToken, // handle to a token representing the logged-on user
pszApplicationName, // name of executable module
(LPTSTR)commandLine, // command line string
psProcessAttributes, // process security attributes
psThreadAttributes, // thread security attributes
bInheritHandles, // whether new process inherits handles
dwCreationFlags, // creation flags
pvEnvironment, // pointer to new environment block
pszCurrentDirectory, // pointer to current directory name
&sStartupInfo, // pointer to STARTUPINFO
pi // pointer to PROCESS_INFORMATION
);
该过程在远程机器上执行,当同步发生时,应该在远程数据库和统一数据库之间交换消息。
如果我从 Windows 命令提示符执行上述命令行,则同步成功。但是,当 CreateProcessAsUser 在预定时间触发时,我在日志文件中看到以下错误消息:
日志文件:
一、2013-04-11 11:17:11。发送消息给“BTI”
I. 2013-04-11 11:17:11。sopen "\\IPaddress\Databases\Production\messages\consolid\Rem00005.g" 失败 1326:无效参数
I. 2013-04-11 11:17:11。sopen "\\IPaddress\Databases\Production\messages\consolid\Rem00005.h" 失败 1326:无效参数
I. 2013-04-11 11:17:13。sopen "\\IPaddress\Databases\Production\messages\consolid\Rem00005.i" 失败 1326:无效参数
I. 2013-04-11 11:17:13。sopen "\\IPaddress\Databases\Production\messages\consolid\Rem00005.j" 失败 1326:无效参数
I. 2013-04-11 11:17:13。sopen "\\IPaddress\Databases\Production\messages\consolid\Rem00005.k" 失败 1326: 无效参数
E. 2013-04-11 11:17:
一、2013-04-11 11:17:13。重新发送请求正在排队
I. 2013-04-11 11:17:14。执行完成
其中“\\IP address\Databases\Production\messages\consolid”是服务器上复制来自远程计算机的消息的文件夹
我请求你的帮助。为什么我能够从命令提示符同步,为什么不能从“CreateProcessAsUser”同步?为什么进程无法将消息发送到服务器上的上述路径。
我已经尝试过的几件事:
我正在使用我的 Windows 域名和凭据以及在代码中使用 ::LogonUser() 登录到应用程序。我已经仔细检查了我发送的凭据是否有效。
使用资源管理器,我可以成功导航到服务器上的上述路径并可以添加/删除文件。
我已将我的用户 ID 添加到管理工具 >> 本地安全策略下的“本地安全设置”中。
任何建议表示赞赏。