I cannot figure out what I'm doing wrong. I have a batch file starting a vbs script. The script just makes some operations in some files, like moving them, create, delete... It works fine. Executing the bat it starts the vbs script and everything work. The bat file just makes a cscript file.vbs
The problem is that I've scheduled this bat file . When the times come, it gets executed but I get the error "path not found" in the vbs script.
It's not a schedule task problem because I've 11 task running batch files and they run smootly, and the script is executed (I've put controllers on it). But the vbs script returns always the same path not found error.
Again,if I execute the script manually, it runs without problems.
The task is scheduled with the same account I use to manual execute the file, so it's not a permission issue. I just doubleclick the batch and it runs, click on execute on the task schedule manager and it fails.
The system is windows server 2008 r2 standard. I already tried to reboot, deleting and making a new task....
Thanks to everyone
[UPDATE]
I paste here part of the code
FILE: D:\scripts\conf.ini
[script1]
fileA=D:\Rep\exportA.csv
fileB=D:\Rep\exportB.csv
fileC=D:\Rep\exportC.csv
dirHistory=D:\Rep\history
FILE: D:\scripts\merge.vbs
Dim iniObj
Set iniObj=New ClsINI
If iniObj.OpenINIFile("D:\scripts\conf.ini") = False Then
wLog("Impossible to read file ini")
Set iniObj = Nothing
Chiudi()
End If
Dim errIni,tmpVal
Dim fileA,fileB,fileC,dirHistory
errIni = iniObj.GetINIValue("script1", "fileA", fileA)
tmpVal = iniObj.GetINIValue("script1", "fileB", fileB)
errIni = errIni+tmpVal
tmpVal = iniObj.GetINIValue("script1", "fileC", fileC)
errIni = errIni+tmpVal
tmpVal = iniObj.GetINIValue("script1", "dirHistory", dirHistory)
errIni = errIni+tmpVal
If errIni > 0 Then
wLog("Error loading file ini")
wLog(errIni)
iniObj.CloseINIFile()
Set iniObj = Nothing
Chiudi()
End If
wLog("File ini Caricato")
Dim objFso,posizioneFile,Fase
Dim arrElement,resArray,actionArray,cedoleArray,varArray ,i
Dim conn,rs,strCon
Dim maxPos,maxTemp
Dim objExcel, objSheet,cella
Set objFso = CreateObject("Scripting.FileSystemObject")
if objFso.FileExists(fileA) then
objFso.DeleteFile(posizione)
wLog("File posizione moved")
else
wLog("File posizione not found")
end if
At this line a get the error of "Path not found"
Set posizioneFile = objFso.OpenTextFile(fileA, 8, True)
If not objFso.FileExists(fileB) then
SendEmail("nego")
Fase=false
Else
Set tFile = objFso.OpenTextFile(fileB, 1)
strFile=tFile.ReadAll
tFile.Close
posizioneFile.WriteLine strFile
objFso.MoveFile fileB, dirHistory&"\Negoz_"& CreaId(2) & ".csv"
End If
posizioneFile.Close
FILE: D:\scripts\merge.bat
echo Start Merge %date% %time% >> Started.log
cscript D:\scripts\merge.vbs
Sorry if I didn't put it before, but I was thinking it was a windows issue, because I thought the code was fine.
Thanks
fileAwhen you get that error? Add a lineWScript.Echo fileAbefore the line that raises the error and check if a) you get an absolute path and b) the path exists. If you get a relative path, check the working directory (WScript.Echo objFso.GetAbsolutePathName(".")) if the path exists inside it. - Ansgar WiechersWScript.Echo objFso.FileExists(fileA) : WScript.Echo objFso.FolderExists(objFso.GetParentFolderName(fileA)). Also double-check thatfileAcontains an actual file name (i.e. does not have a trailing\). - Ansgar Wiechers