Getting error while running a batch file on a Computer connected through LAN
Posted on 2008-11-07
I Posted the question recently, but was unable to present in a proper manner. So started another question with specific information.
I am trying to access a folder located in a shared folder of another computer . I have read permissions to that folder. But once I am through with completion of my data, I want to wite that Data to that Read Folder.
So through this code I am using some developer's login Id and password who has got Write permissions on that folder.
I am using CreateProcessWithLogonW function for this purpose, but it is throwing return code --"0"
In sCmd - I am passing the information to run a batch file which contains the list of parts to be copied and source and destination info.
Res = CreateProcessWithLogonW(StrPtr(sUsername), StrPtr(sDomain), _
StrPtr(spwd), LOGON_WITH_PROFILE, 0&, StrPtr(sCmd), 0&, ByVal 0&, _
StrPtr(sDir), SInfo, PInfo)
If Res <> 0 Then
dwWait = WaitForInputIdle(PInfo.hProcess, INFINITE)
Debug.Print "user input ready..."
' do something when app ready for input
dwWait = MsgWaitForMultipleObjects(1, PInfo.hProcess, 0, INFINITE, QS_ALLINPUT)
Loop Until dwWait = WAIT_OBJECT_0
Debug.Print "process closed/terminated"
' do something when launched app terminates
MsgBox "CreateProcessWithLogonW() failed with error " & Err.LastDllError, vbExclamation
And Err.LastDllError throws a return code --"1058"
The description of this error ---> The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.
What could possibly be wrong in this code ?
What kind of services do we need to start before execution or during execution ?
Please help me with this problem.