I need to do a downloadable Windows batch file (.bat) which runs lpr command on clients machine. That's easy. The hard part is that the batch file must include the data to be printed also. Everything needs to be in one downloadable-file that could be ran by the enduser.
Is there any way to include .prn file (Print-to-file -file) in batch file? Or can I somehow include the printer data on lpr command?
Thanks!
As far as know you cannot include print data in your lpr command. You can specify the file to print and that is it. But do you know the printer name of all the clients? It sounds like there might be a better way of deploying if the clients are on the same network.
You cannot include a .prn file in a .bat (or .cmd) file in any reasonable way (even if the .prn file is a text file). Again if clients are on the same network the .bat file (or .cmd) could access the .prn file stored in a shared place.
Lpr: Sends a file to a computer
running Line Printer Daemon in
preparation for printing.
Syntax
lpr [-S ServerID] -P PrinterName [-C
BannerContent] [-J JobName] [{-o | -o
l}] [-d] [-x] FileName
"The hard part is that the batch file must include the data to be printed also. Everything needs to be in one downloadable-file that could be ran by the enduser."
I'm a little unclear on this, however to me it sounds like you want the batch script to include the text of the data you wish to print?
It looks as if you can have the information in say a .txt file and pass it through lpr:
lpr -P printername -x file.txt
If you need information from a .prn file inside of this printed .txt file, you can try:
TYPE file.prn>>file.txt
However not sure if TYPE will work on a .prn file.
Related
I need to export/import my spk file via windows Batch script.
For which I have been referring this document
But this document does not mention how to save the file (I mean with which extension .bat or .sas)
My command:
ExportPackage -profile "SAS_MW_TEST" -package "F:\mypath\Package4.spk" -objects "/_Applications/_05_MW/_01_SAS_MW/_20_Processes/savedesk(Folder)" -subprop -types "Condition,BusinessRuleFlow,ExternalFile,Cube,SearchFolder,Table,GeneratedTransform,OLAPSchema,InformationMap.OLAP,Measure,Column,Job.CubeBuild,Action,Library,MiningResults,DeployedJob,CalculatedMeasure,Hierarchy,InformationMap.Relational,RootFolder,Prompt,Document,ConditionActionSet,DecisionLogic,Dimension,Note,StoredProcess,PromptGroup,Job,OrchestrationJob,MessageQueue,Service.SoapGenerated,Level,SharedDimension,DeployedFlow"
ExportPackage is an executable program that you can run out of a batch file.
Use Notepad or any other text editor (which includes any SAS code editor), place the ExportPackage program command in the editor and use the File/Save As feature to save the file as something like myPackageExporter.bat
If the items in the package are say stored processes whose metadata says the source code is in an file system folder (aka source code repository), you will probably also want to zip up the folder.
This macro can help you prepare the batch script, ready for export: https://core.sasjs.io/mm__spkexport_8sas.html
I am using Ttermpro.exe to run TTL file. After that, teraterm will display all the output. I want to insert the display in teraterm into logfile.txt by using batch file command. Any idea on how to resolve this problem?
"C:\Program Files (x86)\teraterm\ttermpro.exe" /L=C:\0465\PCU 90000465\UartLog.txt "C:\0465\PCU 90000465\COM.TTL"
I don't know if this answers your problem directly, but based on what I think you're saying, try:
In the teraterm ttl file, include this to avoid the logging command in TTermPro:
logopen 'C:\0465\PCU 90000465\UartLog.log' <binary flag> <append flag>
... more content
... and when done
logclose
The binary flag and append flag can both be set to zero, but you can find more info here: https://ttssh2.osdn.jp/manual/en/macro/command/logopen.html
Generally, I thought the log file was a .log extension, but if you really want it to become a .txt file, you could also add after the logclose function
filerename 'C:\0465\PCU 90000465\UartLog.log' 'C:\0465\PCU 90000465\UartLog.txt'
As far as the batch file goes, you'd simply change directories to the teraterm TTermPro executable and then run the command to execute the macro.
cd C:\Program Files\teraterm
TTERMPRO /M="C:\0465\PCU 90000465\COM.TTL"
but you can also achieve the same thing just using the TTPMacro as
cd C:\Program Files\teraterm
TTPMacro /M=C:\0465\PCU 90000465\COM.TTL
Just save one of those two sets of commands as a .bat file and that should hopefully work.
So i am converting excel files into a .txt files using vbs, and the input file name needs to be the same as the output file name with the changed file extension obviously. Whats making this so hard is the fact that I using this as basically a file converter so the names of the files will be random.
The way I load the input file is by is using the %1 command and just pass in the input file after I call the batch like this.NOTE: the .xlsx can be changed to any .xlsx file that i need to convert.
C:\tabdim>conversion_batch_file.bat **C:\tabdim\2160707.xlsx**
In the batch file (C:\tabdim\conversion_batch_file.bat) Note: the rest of the sql has been replaced with x's.
%windir%\SysWow64\wscript.exe C:\tabdim\combined.vbs **%1**
sqlcmd - xxxxxxxxxxxxxxxxxxxx
bcp xxxxxxxxxxxxxxxx "**C:\tabdim\20160707.txt**" xxxxxxxxxxxxxx
sqlcmd - xxxxxxxxxxxxxxxxxxxx
If there was any way to do something like this
"%1- last 4 characters+".txt""
I know that is totally wrong syntax, I'm just kind of using words to describe kind of what I'm trying to have happen.
I can find plenty of answers on the internet about how to open a specific file, e.g. http://answers.yahoo.com/question/index?qid=20080102230630AAfu5dF
However, I need to provide a way of opening a non-specific file in a program called by a batch file.
To explain, here is an example. The user has a folder with 100 files in with the .xyz extension. He wants to be able to double click on ANY file and open it in his "XYZ Viewer," but to run his XYZ Viewer he needs to run a batch file that alters his registry and then runs the actual XYZ Viewer .exe.
If you select the batch file to be the default program via the "Always use the selected program to open this kind of file" tickbox, it will open the program, but without using the standard Windows function of opening the file that instigating the running of the program.
Is there a way to run the program through the batch file and for it to both run the program and open whichever file it was that instigated the running of the program?
I suspect this is impossible, but any suggestions would be very gratefully received!
Cheers.
Edit:
The program does eventually support opening a file placed as an argument to it.
My code is
reg import c:\regent\31.2.03.reg
start C:\Program\Program.exe
Does the program eventually support opening a file placed as an argument to it? In the example you linked, mspaint opens the first parameter given to it.
If your batch file isn't currently doing this, you will have to edit it to contain the batch parameter(s).
See http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true for some fuller documentation on it.
Essentially you want to add %1 somewhere like:
reg import c:\regent\31.2.03.reg
start C:\Program\Program.exe %1
Is it possible to detect file format and encoding of file using batch files? And if a particular file is not of intended format, throw an error?
As a *nix guy, I'd want to jump for something more powerful than a batch file, such as Python. (or a shell script, but I'm assuming you're using Windows --- you might look into PowerShell, but I've never tried it.)
Unix has a great utility for this sort of thing, it's named file. There appears to be a Windows version here: http://gnuwin32.sourceforge.net/packages/file.htm
Basically, you run file [your filename here] and file spits out a blurb about the file. For example:
$ file zdoom-2.4.1-src.7z
zdoom-2.4.1-src.7z: 7-zip archive data, version 0.3
It's not always right, and it doesn't mean that if file says "this is a JPEG" that the file is actually a JPEG: it could be corrupt, etc.
Also, if I rename the above 7z archive to "foo":
$ file foo
foo: 7-zip archive data, version 0.3
... file will still get it.