Re: How to print from a script



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
.



Relevant Pages

  • [kde] @ Dotan: As requested (back in March, sorry): Hotkey launcher scripts
    ... special konsole window with its own kwin window rules. ... script tho there's independent hotkey solutions out there too, ... The last bit of the puzzle is that I run a separate konsole ...
    (KDE)
  • Re: Pop-up form sending data to the calling form?
    ... I have saved your blog to my favorites and will try it out later. ... How to create a postback on a main page from a popup window ... Basically you can just set them with script, but you can also do it via ...
    (microsoft.public.dotnet.framework.aspnet)
  • Internet Explorer Script Interjection Code Execution (updated)
    ... Internet Explorer Script Interjection Code Execution ... Internet Explorer 7.0 on Windows XP and Windows Vista ... As with all window messages, ... otherwise enter a message loop, ...
    (Bugtraq)
  • Re: [kde] Activity epiphany
    ... power user comfortable at the command line and with scripting. ... an automated method to batch a bunch of apps with their content together, ... the intuitive answer is to write a script. ... whatever, using command line options, so the appropriate kwin window ...
    (KDE)
  • Re: [kde] Activity epiphany
    ... power user comfortable at the command line and with scripting. ... an automated method to batch a bunch of apps with their content together, ... the intuitive answer is to write a script. ... whatever, using command line options, so the appropriate kwin window ...
    (KDE)