I have a rtf file with data and now I have created a temp file and batch file . Now how do I run wordpad print and delete tempfile in progress 4gl
you can use the write.exe command line options:
write.exe /pt someFile.rtf "Microsoft XPS Document Writer"
Here the "Microsoft XPS Document Writer" printer is used. You can list available printers with powershell "get-WmiObject -class Win32_printer | ft name, systemName, shareName"
You use the OS-COMMAND method. You can do that to invoke any os-command in any supported OS.
OS-COMMAND [option] VALUE("whatever command you like to run").
There are three different options
SILENT
After processing an operating system command, the AVM shell pauses. To exit the window in Windows GUI platforms, you must type exit. To exit the window in Windows character platforms, you must type exit and press RETURN or SPACEBAR. You can use the SILENT option to eliminate this pause. Use this option only if you are sure that the program, command, or batch file does not generate any output to the screen. Cannot be used with NO-WAIT.
NO-WAIT In a multi-tasking environment, causes the AVM to immediately pass control back to next statement after the OS-COMMAND without waiting for the operating system command to terminate. Cannot be used with SILENT. This option is supported in Windows only.
NO-CONSOLE While processing an operating system command, the AVM creates a console window. The console window may not be cleaned up after the command is executed. You can use the NO-CONSOLE option to prevent this window from being created in the first place.
Related
My code in the .bat looks like this.
"C:\users\reshade injector.exe"
C:\pathtogame\game.exe "added argument"
"c:\users\reshade injector.exe" <- if I open the actual file, it opens a command window and waits for my other application to launch. Is this a console app?
C:\pathtogame\game.exe "added argument" <- this works and launches my game
Another issue is that when launching the first .exe, a command window stays open. How do I make the command window not appear?
Can anyone help me with these two problems?
*edit for clarity
by opening the actual file, I mean double-clicking on the original reshade injector.exe.
When opening reshade injector.exe, two cmd windows open. They close as soon as I launch the game.exe.
I can't seem to get the reshade injector.exe to launch through the .bat file.
Batch will run any application it finds. If the application does not terminate (eg. it's waiting for user-input) then it will progress to the next instruction.
Some applications work by launching another (the user-interface) and then terminating, leaving the second application resident.
There's no way to tell without observing which approach any random application may take.
So - your batch should execute a file named c:\users\reshade injector.exe.
You say that "fails". Is there an error message generated? You would likely need to run the batch from the "command prompt" to see that message. Note that the Space between reshade and injector must be in the actual filename. If injector.exe is a file in a subdirectory called reshade, then you need a backslash between reshade and injector.
Having resolved the actual name of the first executable, try
#echo off
setlocal
start "" "firstexecutablename"
start "" "secondexecutablename" "arguments"
The first two lines prevent "command echoing" which is used for debugging and establish a "local environment" which ensures the "environment" for the batch file remains unchanged when the batch terminates. In the current case, these two lines are probably unnecessary, but it's SOP for batch files.
The batch should then close its session and window once it has attempted to launch the two applications.
The "" following start becomes the window-title. It can be any quoted string you like, but should not be omitted as start uses the first quoted string it finds as a window-title and may not recognise it as part of the executable/arguments.
I have a script that initializes terminal and prints information in it in Trace32 terminal and I cannot edit that file. I am using term.write command to log the contents in terminal window to a file. But it does log the information that were written before executing this command.
So, I tried to Printer.file and winprint.term.view commands. Now I get this error.
terminal window with this configuration already open
What should I do to log all the contents of terminal (including contents that were already written and will be written in the terminal) to a file?
If you want to get the content from a window in TRACE32 while using the debugger interactively, click on the context menu, and choose "To Clipboard all". Then open a text editor and paste your clipboard to an empty document (Ctrl+V).
If you want to get the content of a window in TRACE32 via a PRACTICE script use the command PRinTer.FILE <FilenName> ASCIIE (as you did) and then the command WinPRT <WindowName> /ALL.
The pre-command WinPRINT creates a new window on the printer, which will not give what you want with Terminal windows. The command WinPRT however, actually sends the content of an open window to the printer (and the printer can be redirected to a file).
The tricky thing with WinPRT is to know the name of your window. The command WinPOS allows you set the name for next opening window. So I recommend to use WinPOS in the script opening your terminal window. But since you can't change that script use the command WinPAGE.List to get the names of all open windows.
E.g. In the following WinPAGE.List you can see that the window opened with TERM.VIEW has the window-name "W000".
Thus, I can get the content of my terminal window with
PRinTer.FILE "C:\temp\mywindow.txt ASCIIE
WinPRT W000 /ALL
Note, that window names are case sensitive.
The window names starting with a capital 'W' followed by three decimal digits are set by TRACE32 in the order they appear. So if you want to be sure that your terminal window always gets the same name, ensure that no window is open before opening your terminal window with your script. You can close all windows with WinPAGE.RESet.
So all together you get:
WinPAGE.RESet
DO "C:\T32\user\my_script_to_open_the_terminal.cmm"
PRinTer.FILE "C:\temp\mywindow.txt ASCIIE
WinPRT W000 /ALL
If you script is only opening one terminal window and no other window, I recommend to do this:
WinPOS ,,,,,,myTerminal
DO "C:\T32\user\my_script_to_open_the_terminal.cmm"
PRinTer.FILE "C:\temp\mywindow.txt ASCIIE
WinPRT myTerminal /ALL
I am late, but figured out the answer.
&LOGFILENAME=OS.PPF()+".log" ; so, filename here is "<this_current_path_filename_with_extension>.log"
PRINT " Printing to log file: &(LOGFILENAME)"
PRinTer.FILE &LOGFILENAME ASCIIE
; select and open display the AREA you want to print to file; here it is default T32 log area A000
AREA.Select A000
AREA.View A000
WinPrint.AREA.View
;AREA.CLEAR ;if you want to clear the view for next set of prints
Alternatively, in real-time, write-to-file is
OPEN #1 OS.PPF()+".log" /CREATE ; so, filename here is "<this_current_path_filename_with_extension>.log"
;...
WRITE #1 "Hello World - it is " DATE.TIME()
;how many ever WRITE's you want in the code
;...
;...
WRITE #1 " BYE"
;...
CLOSE #1
I have got a batch script that ends with the following:
TITLE ALL DONE. You can close this window
ECHO.
ECHO ALL DONE. You can close this window
ECHO.
Pause
EXIT
it works fine when i run just the bat file (see below)
All Done! You can close this window.
Press any key to continue . . .
But when i create a self extracting exe out of the same bat script it wouldn't show this window after the execution and would just exit without any proper message.
Since the script works fine by itself, i am a bit lost on what could be causing this? How could i make the self extracting exe to show that window and prompt the user to close it like above.
It depends on the content of the executable, if your including other files to your archive be sure the program you run after extraction is your batch file.
If your only including that file i suggest you use BatToExe Converter
much more efficient way to build it, also it supports commandline, including other files, product info, admin manifest etc
I have a legacy application which doesn't support utilizing the default applications defined in windows which requires that I specify a specific an executable for a file format to be opened within the application. Since Microsoft no longer includes MODI with Office by default I have been looking at using launching Windows Picture Viewer for .TIF, .TIFF, & .BMP files since it is built into Windows; however Microsoft does not have a direct executable for Windows Picture Viewer which can be called forcing me to create a script which executes the command which calls for Windows Picture Viewer to execute. After research the only way I have been able to call the application to open a specific file is by creating a batch file such as below:
GIFTS.BAT
rundll32.exe C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscreen %~1
If I execute the above code such as GIFTS.BAT "C:\Example Directory\Sample File.tif" from a command prompt or from the application launches and the Sample File.tif opens without a problem; however a command prompt opens along with the file when launching from the application.
Upon which I tried to create a vbscript to hide the batch file from executing however I can't seem to pass my argument if the argument has a "space" within the argument.
GIFTS.VBS
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """C:\GIFTS.BAT"" " & WScript.Arguments.Item(0), 0
Set WshShell = Nothing
If I try to execute the VBScript from a command prompt such as GIFTS.VBS "C:\Example Directory\Sample File.tif" the application never launches and the command prompt returns no message or error. If I simplify the execute command (removing spaces to GIFTS.VBS "C:\Sample_File.tif" the application launches as well as the file Sample_File.tif is displayed and there is no command prompt displayed when the application executes the VBScript.
My question is how can I pass an argument into the VBS script that in return passes the the batch file when the argument contains spaces (which there is always going to be spaces since the argument will be a file name and path)?
There might be an easier approach to what I want to accomplish; however I am looking for a solution that Windows 7 - 8.1 can utilize with no additional software to install or manage on each workstation. The batch files works great I just need to be able to hide the command prompt that opens along with the application as my end users won't know what to do with it.
Thanks!
Sometimes, nested levels of escaping characters requires intimate knowledge of the undocumented behavior of CMD or some voodoo. Another way to attack the problem is to guarantee that you won't have any spaces in the name of the file. Windows has a concept of a short path (no spaces or special chars) for which every existing file has a unique one.
Here's a modified version of your program for which invoked subcommand doesn't need quotes around the file name.
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFile = fso.GetFile(WScript.Arguments.Item(0))
WshShell.Run """c:\GIFTS.BAT"" " & fsoFile.ShortPath, 0
Set WshShell = Nothing
You may wish to add your own error checking. The specified file must exist in order for the GetFile() command to succeed.
I currently have a Windows batch file that runs an .exe file that uses a text file. I am trying to have the Windows batch file run the .exe file multiple times. This, however, requires the use of the same text files to read from. The command prompt gives me the error that the ".txt could not be opened" (I assume from this that it is already open.)
I am trying to see if there is a way in a .bat file to system call to kill that specific text file. The suggestions I see online are to use 'taskkill notepad.exe', but that returns "invalid argument" because the program doesn't open Notepad to use the text file.
Any suggestions would be appreciated.
It sounds like your existing script fails because the first instance of the exe is still open when the second instance starts.
One thing worth trying (and this depends on the nature of the application you are invoking) is to start the executable using the START /WAIT /B ... command. This makes the command interpreter wait for the program to exit before it moves onto the next command, so as long as nothing else is locking the text files you should be OK to move onto the next command.