Let's start with a copy of the scripts involved here - please don't make fun of my hack job I'm just a baby coder here
this is run on a W2KPRO workstation
NO_PRINT.VBS
NO_PRINT.VBS invokes the html page below as a script status updater...
PrntStat.html
<HTML><HEAD><TITLE>Progress Indicator</TITLE>
<SCRIPT>
var timerID = null;
var timerOn = false;
var startDay = new Date();
var startTime = startDay.getTime();
var now = new Date();
var dayMonth = now.getDate(); // day of the month {1-31}
var month = now.getMonth(); // present month {0-11}
var year = now.getYear(); // present year {0-99}
var dayWeek = now.getDay(); // day or the week {0(Sun)-6}
var weekDay = "";
var yearMonth = "";
function stopclock(){
if(timerOn) clearTimeout(timerID);
timerOn = false;
}
function startclock(){
stopclock();
showtime();
}
function showtime(){
var now = new Date();
var hour = now.getHours(); // present hour {0-23}
var minute = now.getMinutes(); // present minute {0-59}
var second = now.getSeconds(); // present second {0-59}
var timeOn = now.getTime();
var timeValue = " " + ((hour > 12) ? hour - 12 : hour);
timeValue += ((minute < 10) ? ":0" : ":" + minute;
timeValue += ((second < 10) ? ":0" : ":" + second;
timeValue += (hour >= 12) ? " P.M." : " A.M.";
document.clock.face.value = timeValue;
var timerTime = (timeOn - startTime)/1000;
var timerTimS = "" + timerTime // convert to a string
timerTimS = " "+timerTimS.substring(0,timerTimS.indexOf(".") + "";
document.clock.timespent.value = timerTimS;
timerID = setTimeout("showtime()",1000);
timerOn = true;
}
</SCRIPT></HEAD>
<BODY SCROLL='NO' onLoad="startclock()">
<CENTER>
<FORM NAME="clock" onSubmit="0">
<INPUT TYPE="hidden" NAME="face" SIZE=1 VALUE ="">
<INPUT TYPE="text" NAME="timespent" SIZE=1 VALUE =""></FORM>
<FONT FACE='arial'><FONT SIZE=2><HR COLOR='BLACK'><B><DIV id='MakeMeAnObject'></B></DIV>
<HR COLOR='BLACK'></FONT></CENTER>
</BODY></HTML>
[/code]
Now what I have been unable to do is:
1) Count only the .SPL files in C:\WINNT\system32\spool\PRINTERS and multiply the result by 0.1
2) Use that SPL's * 0.1 result and set each "WScript.Sleep 130000" in NO_PRINTS.VBS dynamically per search set.
3) Watch the "SPOOLSV.EXE" (Print Spooler) service's CPU or CPU TIME activity to determine when all print jobs are complete and then pause the active printer and go delete the left over .SHD files from C:\WINNT\system32\spool\PRINTERS (each .SPL file has a corresponding .SHD file associated with it).
Once I figure this out I can also watch the ivoicing application's process to determine when to fire off the searches...
If I can't watch the service persay then maybe I could catalog the \spool\PRINTERS directory and poll it every so often to see if all the originally cataloged .SPL files are gone
I'm really stuck on this one and just can not figure it out. I would appreciate some help if possible.
I also know that I could break each search into its own script and call the next "phase" from within each script, but right now I modify the sleep time by hand (I multiply the # of documents showing in the print queue * 0.1, round UP to the nearest second).
Thanks to anyone that even took the time to peek in here
DigiMahn
this is run on a W2KPRO workstation
NO_PRINT.VBS
Code:
set WshShell = CreateObject("WScript.Shell")
Set IE = CreateObject("InternetExplorer.Application")
Set shl = CreateObject("Shell.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a path and filename to a file in My Documents
strMyDocPath = WshShell.SpecialFolders("MyDocuments")
strTempFile = strMyDocPath & "\PrntStat.html"
'Run IE, load PrntStat.html, and Set the DIV element as an object
SetupIE(strTempFile)
Set objDIV = IE.Document.All("MakeMeAnObject")
'Change the innerHTML of the DIV object
objDIV.InnerHTML = "Processing Search Script..."
WScript.Sleep 2000
'Start Search and set params for search
shl.FindFiles
WScript.Sleep 1000
WshShell.SendKeys "{TAB 2}"
WshShell.SendKeys "{DOWN 5}"
WshShell.SendKeys "C:\WINNT\system32\spool\PRINTERS"
WshShell.SendKeys "~"
'Find and Delete all "GAP" invoices
WshShell.SendKeys "{TAB 10}"
WshShell.SendKeys "{BS 10}"
WshShell.SendKeys "{DELETE}"
WshShell.SendKeys "*.SPL"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "GAP "
SetupIE(strTempFile)
Set objDIV = IE.Document.All("MakeMeAnObject")
objDIV.InnerHTML = "Locating GAP Invoices...<BR><FONT SIZE=1>Next process: Locate and Delete American Eagle's invoices"
WScript.Sleep 1000
wshShell.AppActivate "Search Results"
WshShell.SendKeys "~"
WScript.Sleep 130000 '2m10s
wshShell.AppActivate "Search Results"
WshShell.SendKeys "%ea"
WshShell.SendKeys "+{DEL}"
WshShell.SendKeys "~"
'Find and Delete all "AMER150" invoices
WshShell.SendKeys "{TAB 4}"
WScript.Sleep 100
WshShell.SendKeys "AMER150 "
SetupIE(strTempFile)
Set objDIV = IE.Document.All("MakeMeAnObject")
objDIV.InnerHTML = "Locating American Eagle Invoices...<BR><FONT SIZE=1>Next process: Locate and Delete Skin Market's invoices"
WScript.Sleep 1000
wshShell.AppActivate "Search Results"
WshShell.SendKeys "~"
WScript.Sleep 130000 '2m10s
wshShell.AppActivate "Search Results"
WshShell.SendKeys "%ea"
WshShell.SendKeys "+{DEL}"
WshShell.SendKeys "~"
'Find and Delete all "SKIN3910" invoices
WshShell.SendKeys "{TAB 4}"
WScript.Sleep 100
WshShell.SendKeys "SKIN3910"
SetupIE(strTempFile)
Set objDIV = IE.Document.All("MakeMeAnObject")
objDIV.InnerHTML = "Locating Skin Market Invoices...<BR><FONT SIZE=1>Next process: Locate and Delete Charlotte Russe[1]'s invoices"
WScript.Sleep 1000
wshShell.AppActivate "Search Results"
WshShell.SendKeys "~"
WScript.Sleep 130000 '2m10s
wshShell.AppActivate "Search Results"
WshShell.SendKeys "%ea"
WshShell.SendKeys "+{DEL}"
WshShell.SendKeys "~"
'Find and Delete all "CHAR4645" invoices
WshShell.SendKeys "{TAB 4}"
WScript.Sleep 100
WshShell.SendKeys "CHAR4645"
SetupIE(strTempFile)
Set objDIV = IE.Document.All("MakeMeAnObject")
objDIV.InnerHTML = "Locating Charlotte Russe[1] Invoices...<BR><FONT SIZE=1>Next process: Locate and Delete Charlotte Russe[2]'s invoices"
WScript.Sleep 1000
wshShell.AppActivate "Search Results"
WshShell.SendKeys "~"
WScript.Sleep 130000 '2m10s
wshShell.AppActivate "Search Results"
WshShell.SendKeys "%ea"
WshShell.SendKeys "+{DEL}"
WshShell.SendKeys "~"
'Find and Delete all "CHAR1175" invoices
WshShell.SendKeys "{TAB 4}"
WScript.Sleep 100
WshShell.SendKeys "CHAR1175"
SetupIE(strTempFile)
Set objDIV = IE.Document.All("MakeMeAnObject")
objDIV.InnerHTML = "Locating Charlotte Russe[2] Invoices...<BR><FONT SIZE=1>Next process: Initialize and Print Daily Invoices"
WScript.Sleep 1000
wshShell.AppActivate "Search Results"
WshShell.SendKeys "~"
WScript.Sleep 130000 '2m10s
wshShell.AppActivate "Search Results"
WshShell.SendKeys "%ea"
WshShell.SendKeys "+{DEL}"
WshShell.SendKeys "~"
WshShell.SendKeys "%{F4}"
'Close Search, Stop/Start Print Spooler, switch to Printer, Refresh and un-pause
WshShell.SendKeys "%{F4}"
intReturn = WshShell.Run("C:\TransFlo\rndprint\Stop_svc.bat", 1, TRUE)
WshShell.AppActivate "HP LaserJet 4000 Series PCL - Paused"
WScript.Sleep 500
WshShell.SendKeys "{F5}"
WScript.Sleep 2000
WshShell.SendKeys "%pa"
SetupIE(strTempFile)
Set objDIV = IE.Document.All("MakeMeAnObject")
objDIV.InnerHTML = "Printing Invoices..."
'IE SUBROUTINES
Sub SetupIE(File2Load)
IE.Navigate File2Load
IE.ToolBar = False
IE.StatusBar = False
IE.Resizable = False
Do
Loop While IE.Busy
IE.Width = 500
IE.Height = 150
IE.Left = 0
IE.Top = 0
IE.Visible = True
WshShell.AppActivate("Microsoft Internet Explorer")
End Sub
NO_PRINT.VBS invokes the html page below as a script status updater...
PrntStat.html
<HTML><HEAD><TITLE>Progress Indicator</TITLE>
<SCRIPT>
var timerID = null;
var timerOn = false;
var startDay = new Date();
var startTime = startDay.getTime();
var now = new Date();
var dayMonth = now.getDate(); // day of the month {1-31}
var month = now.getMonth(); // present month {0-11}
var year = now.getYear(); // present year {0-99}
var dayWeek = now.getDay(); // day or the week {0(Sun)-6}
var weekDay = "";
var yearMonth = "";
function stopclock(){
if(timerOn) clearTimeout(timerID);
timerOn = false;
}
function startclock(){
stopclock();
showtime();
}
function showtime(){
var now = new Date();
var hour = now.getHours(); // present hour {0-23}
var minute = now.getMinutes(); // present minute {0-59}
var second = now.getSeconds(); // present second {0-59}
var timeOn = now.getTime();
var timeValue = " " + ((hour > 12) ? hour - 12 : hour);
timeValue += ((minute < 10) ? ":0" : ":" + minute;
timeValue += ((second < 10) ? ":0" : ":" + second;
timeValue += (hour >= 12) ? " P.M." : " A.M.";
document.clock.face.value = timeValue;
var timerTime = (timeOn - startTime)/1000;
var timerTimS = "" + timerTime // convert to a string
timerTimS = " "+timerTimS.substring(0,timerTimS.indexOf(".") + "";
document.clock.timespent.value = timerTimS;
timerID = setTimeout("showtime()",1000);
timerOn = true;
}
</SCRIPT></HEAD>
<BODY SCROLL='NO' onLoad="startclock()">
<CENTER>
<FORM NAME="clock" onSubmit="0">
<INPUT TYPE="hidden" NAME="face" SIZE=1 VALUE ="">
<INPUT TYPE="text" NAME="timespent" SIZE=1 VALUE =""></FORM>
<FONT FACE='arial'><FONT SIZE=2><HR COLOR='BLACK'><B><DIV id='MakeMeAnObject'></B></DIV>
<HR COLOR='BLACK'></FONT></CENTER>
</BODY></HTML>
[/code]
Now what I have been unable to do is:
1) Count only the .SPL files in C:\WINNT\system32\spool\PRINTERS and multiply the result by 0.1
2) Use that SPL's * 0.1 result and set each "WScript.Sleep 130000" in NO_PRINTS.VBS dynamically per search set.
3) Watch the "SPOOLSV.EXE" (Print Spooler) service's CPU or CPU TIME activity to determine when all print jobs are complete and then pause the active printer and go delete the left over .SHD files from C:\WINNT\system32\spool\PRINTERS (each .SPL file has a corresponding .SHD file associated with it).
Once I figure this out I can also watch the ivoicing application's process to determine when to fire off the searches...
If I can't watch the service persay then maybe I could catalog the \spool\PRINTERS directory and poll it every so often to see if all the originally cataloged .SPL files are gone
I'm really stuck on this one and just can not figure it out. I would appreciate some help if possible.
I also know that I could break each search into its own script and call the next "phase" from within each script, but right now I modify the sleep time by hand (I multiply the # of documents showing in the print queue * 0.1, round UP to the nearest second).
Thanks to anyone that even took the time to peek in here
DigiMahn