Re: How to print from a script
- From: Jeffery Hicks <"jhicks[at]SAPIEN.com">
- Date: Wed, 14 Feb 2007 12:12:03 -0500
On Wed, 14 Feb 2007 08:05:31 -0800, Jrex7 wrote:
I would like to know if there is a way to Print from a script.
I already have a script that looks for specific session names running on
servers. At the end of the script I use the "wscript.echo" method to display
a window showing the results of the script, this window only has an ok
button. What I would like to do is add more code at the end of the scirpt to
come up with another window to give the users the option to print the results
to their default printer or to just exit the script.
Any help on this would be greatly appreciated.
Dim objShell
Set objShell=CreateObject("wscript.shell")
For Each item In objShell.Environment("System")
wscript.echo item
s=s & item & VbCrLf
Next
rc=MsgBox("Do you want to print the
results?",vbYesNo+vbQuestion+vbDefaultButton2,"Print?")
If rc=vbYes Then
Set objFSO=CreateObject("Scripting.FileSystemObject")
strTemp=("c:\~tmp.txt")
Set objFile=objFSO.CreateTextfile(strTemp,True)
objFile.write s
objFile.close
'make sure you wait for the print to finish before deleting the file
objShell.Run "cmd /c Print /d:\\jdhit-dc01\hplaser5 " & strTemp,0,True
objFSO.DeleteFile strTemp
End If
I specify a printer but it should accept the default, unless it is a USB
connected printer.
--
Jeffery Hicks
SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com
VBScript & Windows PowerShell Training -
www.ScriptingTraining.com/classes.asp
Windows PowerShell? - www.SAPIENPress.com/powershell.asp
blog: http://blog.SAPIEN.com
blog: http://jdhitsolutions.blogspot.com
.
- Prev by Date: Re: Login script loging a user out based on day and time...
- Next by Date: Re: Login script loging a user out based on day and time...
- Previous by thread: Re: How to print from a script
- Index(es):
Relevant Pages
|