I've got a task that does a few things then runs a batch file c:\run.bat
The batch file runs a vbscript.
Ive tried to cscript //b the batch and start but no joy.
When I'm logged into the server the task runs fine
However when I log out and with the service running ok, the task runs, the batch runs too, but the running of the csript file does not.
I've synced the task in program folders to match the logged in profile, but no joy.
Any ideas?
The vbscript file is kinda tricky so dont think i could incorporate it into the task.
Running a batch
Running a batch
Last edited by deesloop on Wed Nov 07, 2012 9:13 pm, edited 1 time in total.
Running a batch
Here's the batch file
echo off
del d:\costs\weekly\weekly.txt
del d:\costs\source\source.txt
del d:\costs\intplant\intplant.txt
del d:\costs\extplant\extplant.txt
del d:\costs\wages\wages.txt
cscript //b c:\merge.vbs <- was also call c:\merge.vbs
And here is vbscript
Basically it uses pdftk to merge a bunch of files starting withthe same number and drops them in a directory then create all necessary subfolder and group by that number.
Dim objResult
dim objfile
dim dayt
dim strFolderPath
Set objShell = WScript.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("pdftk 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")
echo off
del d:\costs\weekly\weekly.txt
del d:\costs\source\source.txt
del d:\costs\intplant\intplant.txt
del d:\costs\extplant\extplant.txt
del d:\costs\wages\wages.txt
cscript //b c:\merge.vbs <- was also call c:\merge.vbs
And here is vbscript
Basically it uses pdftk to merge a bunch of files starting withthe same number and drops them in a directory then create all necessary subfolder and group by that number.
Dim objResult
dim objfile
dim dayt
dim strFolderPath
Set objShell = WScript.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("pdftk 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
If I could accomplish this entirely within Robotask - without the batch files/vbscript then that would be good. I have an old version of robotask and if meant upgrading then I would do that.
What are the costs to go from 3.5.2 business usage?
What are the costs to go from 3.5.2 business usage?
Running a batch
What operating system do you use?
What mode of RoboTask (with this task): simple application or system service?
It seems that you try to use this task in application mode.
When you close session then RoboTask application is being closed.
So prepared tasks will not work until you log in again.
Also pay attention that RoboTask application and RoboTask service have different sets of tasks.
RoboTask application keeps own tasks in user's profile folder, by default.
RoboTask service in sub-folder of RoboTask's folder.
Read more here, also see related chapters.
What mode of RoboTask (with this task): simple application or system service?
It seems that you try to use this task in application mode.
When you close session then RoboTask application is being closed.
So prepared tasks will not work until you log in again.
Also pay attention that RoboTask application and RoboTask service have different sets of tasks.
RoboTask application keeps own tasks in user's profile folder, by default.
RoboTask service in sub-folder of RoboTask's folder.
Read more here, also see related chapters.
Running a batch
You have to purchase at least "1 year of free updates"What are the costs to go from 3.5.2 business usage?
This costs 40% from regular price
Running a batch
Its running on a W2k8 machine as a service.
It runs other tasks no problem and it also runs this task too, but fails at running the batch file - namely calling the vbscript.
It's not that the task doesnt run.
It's that the task doesn't run properly.
I've set the batch to run as domain admin and the password is correct and it does run and delted some files
However calling the vb script doesn.t
It runs other tasks no problem and it also runs this task too, but fails at running the batch file - namely calling the vbscript.
It's not that the task doesnt run.
It's that the task doesn't run properly.
I've set the batch to run as domain admin and the password is correct and it does run and delted some files
However calling the vb script doesn.t
Running a batch
What error do get?
Is VB script not starting at all?
I think that you get the error in line
objResult = objShell.Run("pdftk ....
This operation may require user's environment.
I saw that some utilities are working well in user session, but don't want to start in system session (in service mode).
BTW: I don't see operations in your script that you can't implement in the task by using RoboTask actions.
Also you can adapt your script for built-in BASIC of RoboTask
You can download and install it additionally. See here, please, for version 3.5.2
Is VB script not starting at all?
I think that you get the error in line
objResult = objShell.Run("pdftk ....
This operation may require user's environment.
I saw that some utilities are working well in user session, but don't want to start in system session (in service mode).
BTW: I don't see operations in your script that you can't implement in the task by using RoboTask actions.
Also you can adapt your script for built-in BASIC of RoboTask
You can download and install it additionally. See here, please, for version 3.5.2
Running a batch
Rats - so that couldbe the issue then.
I've bought the upgrade - can I jsut install it over the top of my version.
I'd appreciates some help if possible to convert the vbs to a task?
I've bought the upgrade - can I jsut install it over the top of my version.
I'd appreciates some help if possible to convert the vbs to a task?
Running a batch
This can be done manually only.if possible to convert the vbs to a task?
But language of Basic plugin is very similar to VBS.
So you can transfer your VBS to BASIC script with minimal changes.
Running a batch
OK
I'll give it a go.
Can I just install the latest version over what I have now?
I'll give it a go.
Can I just install the latest version over what I have now?