Running a batch
Running a batch
Yes of course.
But in any case I recommend to backup your tasks folder.
This operation is never superfluous.
But in any case I recommend to backup your tasks folder.
This operation is never superfluous.
Running a batch
Hmm.
Well I installit and the BAsic module but I'm struggling with the Basic module
It hates my code.
Set objShell = wscript.CreateObject("WScript.Shell")
Not an Object reference
Thats not handy
Well I installit and the BAsic module but I'm struggling with the Basic module
It hates my code.
Set objShell = wscript.CreateObject("WScript.Shell")
Not an Object reference
Thats not handy
Running a batch
Actually I dopped the wscript. and the error went away
However teh code isn't working
Sub Main
Dim objResult
Dim objfile
Dim dayt
Dim strFolderPath
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder=CreateObject("scripting.filesystemobject").getfolder ("d:\costs\splits")
On Error Resume Next
For Each aFile In oFolder.Files
If sNewest = "" Then
Set fNewest = aFile
sNewest = aFile.Name
Else
If fNewest.DateCreated < aFile.DateCreated Then
Set fNewest = aFile
End If
End If
Next
dayt=(Left(fNewest.Name,10))
Set objfile = objFSO.CreateTextFile("D:\Costs\started.txt")
For lp = 1500 To 2500
objResult = objShell.Run("c:\windows\system32\pdftk.exe d:\costs\splits\????-??-??_" & lp & "*.pdf cat output d:\costs\record\" & dayt & "_" & lp & "_costs.pdf", 1, True)
Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("d:\costs\record")
For Each objfile In objFolder.Files
contract = Mid(objfile.Name, 12, 4)
folder = Mid(objfile.Name, 12, 2)
strFolderPath = "d:\costs\record\" & folder & "00-" & folder & "99\"
If Not objFSO.FolderExists(strFolderPath) Then
Set objFolder2 = objFSO.CreateFolder(strFolderPath)
End If
strFolderPath2 = "d:\costs\record\" & folder & "00-" & folder & "99\" & contract & "\"
If Not objFSO.FolderExists(strFolderPath2) Then
Set objFolder2 = objFSO.CreateFolder(strFolderPath2)
End If
objFSO.MoveFile objfile.Path, strFolderPath2
Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objfile = objFSO.CreateTextFile("D:\Costs\Finished.txt")
However teh code isn't working
Sub Main
Dim objResult
Dim objfile
Dim dayt
Dim strFolderPath
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder=CreateObject("scripting.filesystemobject").getfolder ("d:\costs\splits")
On Error Resume Next
For Each aFile In oFolder.Files
If sNewest = "" Then
Set fNewest = aFile
sNewest = aFile.Name
Else
If fNewest.DateCreated < aFile.DateCreated Then
Set fNewest = aFile
End If
End If
Next
dayt=(Left(fNewest.Name,10))
Set objfile = objFSO.CreateTextFile("D:\Costs\started.txt")
For lp = 1500 To 2500
objResult = objShell.Run("c:\windows\system32\pdftk.exe d:\costs\splits\????-??-??_" & lp & "*.pdf cat output d:\costs\record\" & dayt & "_" & lp & "_costs.pdf", 1, True)
Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("d:\costs\record")
For Each objfile In objFolder.Files
contract = Mid(objfile.Name, 12, 4)
folder = Mid(objfile.Name, 12, 2)
strFolderPath = "d:\costs\record\" & folder & "00-" & folder & "99\"
If Not objFSO.FolderExists(strFolderPath) Then
Set objFolder2 = objFSO.CreateFolder(strFolderPath)
End If
strFolderPath2 = "d:\costs\record\" & folder & "00-" & folder & "99\" & contract & "\"
If Not objFSO.FolderExists(strFolderPath2) Then
Set objFolder2 = objFSO.CreateFolder(strFolderPath2)
End If
objFSO.MoveFile objfile.Path, strFolderPath2
Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objfile = objFSO.CreateTextFile("D:\Costs\Finished.txt")
Running a batch
You can make reference manually. See screenshot:Set objShell = wscript.CreateObject("WScript.Shell")
Not an Object reference
Thats not handy
Next choose "Windows Script host object model"
Now you can write code like this:
Code: Select all
Sub Main
Dim o As FileSystemObject
Set o = New FileSystemObject
o.GetFolder("c:\temp")
End Sub
Last edited by Oleg on Thu Nov 22, 2012 8:09 pm, edited 1 time in total.
Running a batch
write this instead:Actually I dopped the wscript. and the error went away
However teh code isn't working
...
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder=CreateObject("scripting.filesystemobject").getfolder ("d:\costs\splits")
On Error Resume Next
...
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = objFSO.getfolder("d:\costs\splits")
It's working. I've tested this.
Last edited by Oleg on Thu Nov 22, 2012 8:03 pm, edited 1 time in total.
Running a batch
Thanks for that
The code runs but doens't do what its supposed to do
It isnt joinging pdfs together.
No errors are thrown up
I've gone thru the code and everything seems to run OK to the point where the code below should run
objResult = objShell.Run("c:\windows\system32\pdftk.exe d:\costs\splits\????-??-??_" & lp & "*.pdf cat output d:\costs\record\" & dayt & "_" & lp & "_costs.pdf", 1, True)
I'm not getting any feedback from the programme, but when I run the code in the original vbscript it works fine.
Thanks for your assistance thus far though
The code runs but doens't do what its supposed to do
It isnt joinging pdfs together.
No errors are thrown up
I've gone thru the code and everything seems to run OK to the point where the code below should run
objResult = objShell.Run("c:\windows\system32\pdftk.exe d:\costs\splits\????-??-??_" & lp & "*.pdf cat output d:\costs\record\" & dayt & "_" & lp & "_costs.pdf", 1, True)
I'm not getting any feedback from the programme, but when I run the code in the original vbscript it works fine.
Thanks for your assistance thus far though
Running a batch
OK
I stripped the code back to the pdf join utility only
Sub Main
Dim objResult
Set objShell = CreateObject("WScript.Shell")
Dim lp
For lp = 1500 To 2500
objResult = objShell.Run("c:\windows\system32\pdftk.exe d:\costs\splits\????-??-??_" & lp & "*.pdf cat output d:\costs\record\_" & lp & "_costs.pdf", 1, True)
Next
End Sub
It's definitely the pdf join line
I get an error while tracing it
&H8007002 Exception 80070002
Googled it and it says the error suggests cannot find file specified.
now
I know c:\windows\system32\pdftk.exe exists
as does the folder d:\costs\splits and d:\costs\record
I stripped the code back to the pdf join utility only
Sub Main
Dim objResult
Set objShell = CreateObject("WScript.Shell")
Dim lp
For lp = 1500 To 2500
objResult = objShell.Run("c:\windows\system32\pdftk.exe d:\costs\splits\????-??-??_" & lp & "*.pdf cat output d:\costs\record\_" & lp & "_costs.pdf", 1, True)
Next
End Sub
It's definitely the pdf join line
I get an error while tracing it
&H8007002 Exception 80070002
Googled it and it says the error suggests cannot find file specified.
now
I know c:\windows\system32\pdftk.exe exists
as does the folder d:\costs\splits and d:\costs\record
Running a batch
It seems the problem is in PDFTK utility.
"cannot find file specified" may mean that system can't find some component of the program too
I tried to run some program from "c:\windows\system32" folder.
It's working without problems in application mode and in service mode too.
see script below:
This script launches CALC.exe. If it is being used in service mode then it launches CALC.EXE in system session.
"cannot find file specified" may mean that system can't find some component of the program too
I tried to run some program from "c:\windows\system32" folder.
It's working without problems in application mode and in service mode too.
see script below:
Code: Select all
Sub Main
Dim objResult
Dim s As String
Set objShell = CreateObject("WScript.Shell")
objResult = objShell.Run("c:\windows\system32\calc.exe", 1, True)
'RoboTaskApp.WriteToLog(0,CStr(objResult), 0)
End Sub
Running a batch
I've just downloaded PDFTK for Windows and tested this.
This is working in service mode very well.
see script I tested:
It concatenated all t?.pdf files into one PDF file without problems
This is working in service mode very well.
see script I tested:
Code: Select all
Sub Main
Dim objResult
Dim s As String
Set objShell = CreateObject("WScript.Shell")
objResult = objShell.Run("D:\Temp\pdftk\pdftk.exe D:\incomming\t?.pdf cat output d:\temp\rt.pdf", 1, True)
End Sub
It concatenated all t?.pdf files into one PDF file without problems
Running a batch
OK the problem may be becasue of the loop in the code?
It starts at 1500 and works up
But not every one of these iterations has files that match each month
ONe month there may be 1500, 1501, 1502, 1502, 1504, 1506
Next month there may be 1500, 1502, 1505
File not found may be becasue pdftk can't find that file?
This isn't a problem in the script but could it be aproblem within robotask?
Bombs out on error?
*edit*
Nope thats not it
Did an on errore resume next.
Correct code is being generated but nothing getting done
It starts at 1500 and works up
But not every one of these iterations has files that match each month
ONe month there may be 1500, 1501, 1502, 1502, 1504, 1506
Next month there may be 1500, 1502, 1505
File not found may be becasue pdftk can't find that file?
This isn't a problem in the script but could it be aproblem within robotask?
Bombs out on error?
*edit*
Nope thats not it
Did an on errore resume next.
Correct code is being generated but nothing getting done
Last edited by deesloop on Fri Nov 23, 2012 1:45 pm, edited 1 time in total.