Click to See Complete Forum and Search --> : Using DOS Copy command within a shell


Dark Sean
March 19th, 2001, 02:27 PM
Hello,
I am having a devil of a time with this problem.
At my network here at work, if I start my DOS prompt and type the following:
copy C:\labels\myfile.txt \\sean\hp

HP is my printer on my computer and the file prints fine. So I want to add that functionality to a labelmaker that I wrote, but if I try to use the Shell like this:


Shell "copy c:\labels\myfile.txt \\sean\hp"




I have also tried :

Shell "Command.com /c copy c:\labels\myfile.txt \\sean\hp"




and this:

Shell "c:\labels\copy myfile.txt \\sean\hp"




I get the file not found error message, though the file is certainly there.

Any way around this???

Thanks,
Sean

Iouri
March 19th, 2001, 02:43 PM
Try this it works for me


Public Const FILEPATH = "c:\temp\exc.txt" 'exception report
Public Const NETWORKPRINT = "f:\public\nprint"
Public msOutqueue As String ' - outqueue name
Public msServer As String' server name


Call PrintTextFile(FILEPATH) - procedure call

Public Sub PrintTextFile(ByVal sTextFile As String)
'==============================================================================
'this sub shells to DOS and call nprint command to print the text file
Dim r As Variant
Dim sCommandString As String
Dim sQ As String
Dim sServerString As String


'DOS command line -> nprint file.txt q=YourOutqueue s=ServerName nt nb ff

sQ = msOutqueue 'defined in login form
sServerString = msServer & " nt nb ff" 'msServer defined in login form
sCommandString = NETWORKPRINT & " " & sTextFile & " q=" & sQ & " s=" & sServerString


r = Shell("start.exe " & sCommandString, vbHide)
End Sub






Iouri Boutchkine
iouri@hotsheet.com

Iouri
March 19th, 2001, 02:44 PM
Also try this

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Dim lngResult As Long
lngResult = ShellExecute(Me.hwnd,"Print",strFile,0&,0&,vbMinimized)

where strFile is the full path to your file





Iouri Boutchkine
iouri@hotsheet.com

Dark Sean
March 19th, 2001, 03:04 PM
Iouri,
this works only if my file is a registered type, and when it does it opens the program that is registered to it before printing, that is not acceptable for this situation, thanks for the tip though.

What really frustrates me is why a simple FileCopy doesnt work for a printer.
I have tried:

FileCopy "C:\Labels\Myfile.d00" , "\\sean\hp"



And it errors out.

Dark Sean
March 19th, 2001, 03:25 PM
Ok I finally got it, nothing worked until I searched old posts about the FileCopy method, and I found a post that you wrote about the FileSystemObject the CopyFile method!!! it works!!! I should have known, I have always had great success with FSO.
Thanks