anyone who knows the command for save an excel file (xls) to txt (Tab delimited) in an batchfile ? I have a batch file that opens a sertain excel file and the only thing i want now is that the batch file (.cmd) shall save the file as txt.(Tab Delimited) and then Close the file, anyone knows the commands for this ?
There doesn't appear to be appropriate command-line switches available, but here's some VBA code that might get you started.
ActiveWorkbook.SaveAs FileName:="yourfilename", FileFormat:=xlCSV
Related
I am trying to open a .chm file from a batch file.
The batch file has only this text in it :
echo off
start "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm"
If I run the batch file, the commandline opens but nothing further happens.
If I copy paste S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm in start menu/run then it does works.
If I make a shortcut with target "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm" then it also works.
So the command works everywhere, except from a batch file.
What am I doing wrong here ?
It might also be important to know that when I start it from the shortcut, or start menu/runI always get a dialog
We can't verify who created this file. Are you sure you want to open this file ?
I am using Windows 7
EDIT
My problem is not the dialog, my problem is that nothing happens when I open the chm file from a batch file
The Start command is probably seeing your doublequoted string as a title, enter Start /? at the command prompt for its usage information.
Try adding an empty title first:
#Echo Off
Start "" "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm"
I am trying to run a batch file from a different program.
When I run the batch file manually (double clicking the file) it behaves as expected and creates a text file as a result. But when I call the batch file from a program (Winlog SCADA) the text file is not created.
Does anyone know why this happens?
The batch file contains this line of code:
systeminfo |findstr /C:"Time Zone" >UTCTime.txt
and the code that is calling the batch is (Winlog SCADA):
ShellExec(scriptPath,"run",projectPath+"/Settings/",8,".exe","");
The program probably writes to a different folder - try specifying the path to the folder where you want the file.
systeminfo |findstr /C:"Time Zone" >"c:\folder\UTCTime.txt"
Newbie to windows scripting. I need help running the .bat file on the command line so I can test it.
I used Text Document as my editor to create the file (opens up also as Notepad).
I performed file "save as" (ALL FILES). If I open up cmd, I can see the file has a .txt extension (myfile.bat.txt). So if I just type in cmd myfile.bat.txt the editor opens. I am not sure how to execute this correctly.
As for the logic in my batch script, I am basically logging into a remote directory (already created the net mount) and now I want to:
run an executeable file
rename some files.
With some research, I written this so far. I have saved it as a .bat file
# echo off
echo This is a batch file to run an executable and rename some files
pause
--run executable file here, just don't know how to do it
x:
cd x:
rename fileA fileB
Any help, good tips/practice would be great. Thanks.
Type in this command in cmd window:
rename myfile.bat.txt myfile.bat
Now you can run the script by simply invoking:
myfile.bat
or
myfile
(provided there's no myfile.exe or myfile.com in the same directory).
If you need to edit the script further, you can either right click it in Explorer and choose Edit or call the editor from the command window:
notepad myfile.bat
To call a program from the script, simply add its name, if it's in the current directory:
someprogram.exe
or the name with the path, if it's somewhere else:
directory\program.exe
or
d:\directory\program.exe
If the name or the path contain spaces, be sure to enclose the entire name & path string in double quotes:
"d:\directory\program name.exe"
you can just type the full name of the program
eg
"c:\program dir\program.exe"
or you can add the program directory to your path environment variable
set PATH=%PATH%;"c:\program dir"
and just type the program name
program
you can also edit your PATH variable in windows http://support.microsoft.com/kb/310519
NOTE: When you save the file in notepad, you want to save it as filename.BAT and select All Files from the second dropdown. If you don't it still gets saved as a .TXT.
A couple of command to consider:
CSCRIPT cscript /? in CMD
START http://ss64.com/nt/start.html
If you're doing say a VBSCRIPT use CSCRIPT to start it. If you're trying to execute another BATCH script or an EXE, use START
I have a Batch Interface I've created for a DOS program I'm using and I want to add an Option at the End to save the Output of the Batch File to a File, BUT I don't want the Log to be created unless the user says Yes at the END of the Batch File. So Far the Only way I've found to Optionally create a Log file is to Launch the Batch file like this "something.bat >output.txt" BUT that's at the Beginning BEFORE the Batch is even started which is NOT what I want. Any Ideas?
Write your log file to a temporary file, created below the %TEMP% folder. When you ask the user at the end of your program if he wants to keep it, copy your temporary file to the place where the user expects it. Otherwise remove the log file.
I am trying to make a .bat file to edit the redirect in index.asp to be the filename of the file selected via the context menu option .bat file.
I know how to replace the file:
#echo OFF
del/q D:\e-lib\index.asp
copy %1 D:\e-lib\index.asp
but not how to edit the contents so that the redirect within index.asp points to the filename of the file I right-click, i.e the value %1.
I'm not sure about editing a file via DOS BATCH file, but you could easily pump in the contents of the file using the print command (e.g. "something" > file.asp). You could also build a template that reads in a text file via ASP, that has the contents of the data you need to include in your dynamic ASP file.