So I have been working on a simple batch file, that thanks to #Magoo, I was able to solve the first question I had about it.
Now my next question,
Is there a way to automate an answer input.
Since I'm running Windows 7 (this is the current course I am on, in my quest to become a knowledgeable IT guy), I cannot use PowerShell to extract an image, and to my best knowledge, PowerISO is the only program I have found where I can use command lines in a batch file to extract the .iso file that I want, and place it on the drive/directory that I want. However, I came across the need to input an answer 'NoAll' before I could finish the extraction. I'm wondering if there is a way to automate that answer, if needed. It will only be used once, as the NoAll implies.
All the code is correct and the batch file works properly barring this one little hiccup.
Here's my batch file.
echo
cd "C:\Program Files\Windows AIK\Tools\PETools"
call copype amd64 "C:\winpe-amd64"
copy "C:\winpe-amd64\winpe.wim" "C:\winpe-amd64\iso\sources\boot.wim"
copy "C:\Program Files\Windows AIK\Tools\amd64\imagex.exe" "C:\winpe-amd64\iso" & cd "C:\Program Files\Windows AIK\Tools\amd64"
oscdimg.exe -n -bC:\winpe-amd64\etfsboot.com c:\winpe-amd64\iso c:\winpe-amd64\winpe-amd64.iso
cd 'C:\program files\powerISO"
piso extract "C:\winpe-amd64\winpe-amd64.iso" / -od f:
as the extract begins to run, I get a prompt for input, and this is where I would like to be able to automate the 'NoAll' answer.
Thanks in advance!
Since all you need to do it input text, you can simply echo what you want to type and then pipe it to the other command.
echo NoAll|piso extract "C:\winpe-amd64\winpe-amd64.iso" / -od f:
You can use the input file and input redirector '<' to automate most of input. For example, create a text file 'NoAll.txt' with the content "NoAll" (without quotes, and add a newline at the end for 'Enter' key). On the command that needs NoAll, execute it as follow:
piso extract "C:\winpe-amd64\winpe-amd64.iso" / -od f: < NoAll.txt
Related
I try to make a batch file that basically opens all the stuff I need to work. Opening Maya is quite simple, but there's one step further i'd like to do: make it open my last opened file.
if i understand the doc Start Maya from the command line
I could try this:
path/to/maya.exe -command [some MEL commands that may open the last opened file]
But I have no clue how to MEL and I guess for it to work as a windows batch I must keep it as one command line. I try to read the docs but I fail to find anything I can make use of.
python("recent = cmds.optionVar(q='RecentFilesList')[-1]; cmds.file (recent, force=True, open=True)")
Issues:
I can't find a way to correctly parse the quote marks through batch to Maya.
The file command requires to first save the file to work...
Solutions
Thanks to this answer:
use force=Truein cmds.file (recent, force=True, open=True) to force the file command to work without the need to save the file first
use one backslash \ before the commands " to properly parse them to Maya
"path\to\maya.exe" -command "python(\"recent=cmds.optionVar(q='RecentFilesList')[-1]; cmds.file (recent, force=True, open=True)\")"
Usually you replace a " with a \" to get a working mel command. So if you this could work:
"python(\"recent = cmds.optionVar(q='RecentFilesList')[-1]; cmds.file (recent, open=True)\")"
But to be honest I did not test it as a commandline argument.
You can modify the file command with force:
cmds.file(recent, force=True, open=True)
My goal is to automatically open a few specific files from calling a bash script.
P:\ = personal directory
Approach 1:
Example Code Below (filename: test):
run "P:\Notepad++\notepad++.exe" "P:\test1.txt" "P:\test2.txt"
Question 1:
When I do "./test" in the bash shell, it opens up Notepad++.exe with test1.txt and says "P:\test2.txt" doesn't exist. Create it?"
I have both test1.txt and test2.txt in the P:\ drive so I'm not sure why "test2.txt" doesn't exist. Is it only allowed to take one parameter?
Approach 2:
I tried to use an array approach, but it's not working.
array = ("P:\test1.txt" "P:\test2.txt")
run "P:\Notepad++\notepad++.exe" $array[*]
Now it opens up Notepad++.exe with none of the files open and says "P:\test2.txt)" doesn't exist. Create it?"
echo ${ARRAY[0]} Prints the entire array as a string... not sure why
SOLVED See answer below.
Thanks all who helped. Any elegant approach/solution is appreciated too :)
Not sure about the parameters of the run command in bash, but it does seem like there is a need for a filler if you want to open multiple files within any executable.
Solution:
run "P:\Notepad++\notepad++.exe" "P:\test1.txt" "P:\test2.txt" ""
The "" is some kind of filler but ends up allowing you to open notepad++.exe and the two text files.
This is for automation purpose :) Hope it helps other users!
I have a folder of .doc files I would like to convert to .txt format. How can I do that using LibreOffice's command line mode in Windows 7? The files are located in C:\Temp\Test.
Here is how I handled this task using Windows PowerShell
Note: before using LibreOffice from the command line you need to close all existing instances of Libreoffice. This means closing all GUI sessions of LibreOffice as well as inspecting TaskManager for soffice.exe or a LibreOffice process running the background.
One Item:
PS &("C:\Program Files (x86)\LibreOffice 4\program\soffice.exe") -headless -convert-to txt:Text -outdir C:\Temp C:\Temp\test\sample.doc
This created a file sample.txt in C:\Temp from the document sample.doc
Multiple Items:
foreach ($file in Get-ChildItem C:\Temp\test)
{
&("C:\Program Files (x86)\LibreOffice 4\program\soffice.exe") -headless -convert-to txt:Text -outdir C:\Temp C:\Temp\test\$file | Out-Null
}
This created a .txt file for every file in the folder C:\Temp\test
Again: Use task manager to ensure that a previous version of soffice.exe is not running. This means closing existing GUI versions of LibreOffice.
Explanation:
Here is the documentation regarding Starting LibreOffice Software With Parameters. This will explain the soffice.exe command executed above.
Headless mode starts the LibreOffice software without a GUI. What I refer to in the question as 'command line mode'.
-convert-to is an important parameter in this example. When using -convert-to you need to know what the output_filter_name is (Text in the example above). A reference for those names can be found here. The output_filter_name will be the name of the files in that list that have the suffix .xcu
For example, if I wanted to convert my .doc files to .pdf I would use the parameter -convert-to pdf:writer_pdf_Export (untested)
Here is a reference I used when answering this question.
For some reason .exe processes need to pipe to Out-Null to avoid overlapping one another. Go figure.
The solution above was close, but required some alteration on LibreOffice 4.2 / Linux:
soffice --headless --convert-to txt:Text /path_to/file_to_convert.odt
(I did it with odt, the example I followed used doc: http://ask.libreoffice.org/en/question/14130/how-do-i-install-filters-for-the-soffice-command/)
An additional and important thing to add to #kevinaskevin 's answer is - the workaround is:
From the devs via IRC:
LO's "user installation" (i.e., ~/config/libreoffice) isn't designed to be accessed simultaneously by multiple processes; so when one soffice.bin is already running for a specific user installation, additional soffice.bin just forward their cmd line args to the first one and terminate immediately again (i.e., they shouldn't "fail" in the sense of exiting with a non-zero exit value)
if you want an independent headless LO, you can start it with an own user installation, -env:UserInstallation=<file URL to dir>
i want to run exe programs with a bat file. "Alarm Clock.exe" the bat file will be a basic short cut but i will use the text to learn more about bat files. thanks for any help on this matter , it will help me learn a bit more about programing. Maybe with the whole text.
D:\Program Files\alarm \Alarm Clock.exe
example
#echo off
start D:\Program Files\alarm \Alarm Clock.exe
pause
im not sure
Insert Alarm Clock.exe in the batch file with quotation marks.
"Alarm Clock.exe"
Reason for the quotation: There is a blank in the file name.
There's not so much to learn... to run a program with a batch file you just write its name (usually without extension), prepended by its path if it's not in the batch file's working directory or in the PATH.
How do I pipe standard error to a file in a DOS batch file? Piping using >> only pipes the standard output and the standard error still goes to the console.
Details of my issue:
I am running WinRAR via command line, in an automated daily backup. And the following example pipes WinRar's output, but not the error output which is what I want most, to winraroutput.txt:
RAR.exe a -esh -r "E:\backup.rar" "D:\*.*" >> winraroutput.txt
The issue is sometimes files are in use and when they are I want to know they were missed in the archive and record this in a .txt file next to each .rar file in case we ever have to go back. The missing files are easily replaced by reinstalling programs so it's no big deal to replace them, as long as we know they are missing. So it's just information that would be great to know, not necessary, in the time of need.
How do I output just the standard error output to the .txt file and, if possible but not necessary, leave the the regular output to the console?
Bonus points:
Bonus points if you can tell me how to delete the file if it's blank (no errors)! Asked here: How do I Detect (and Delete) a File if it is Empty using a Windows Batch File?.
Try this:
command.exe 2>file.txt
Or if you prefer not to see any errors, send it to nul:
command.exe 2>nul
This should leave std::cout on the console.