Hello,
I don't know if anybody can help me, because I've search a lot without success.
On my DOS Terminal (XP) I send successfully those commands :
doskey CS=call smile.bat $*
CS
or
CS arg1
It works PERFECTLY !
Then I insert these commands in a new batch file :
#echo off
doskey CS=call smile.bat $*
CS arg1
Error returned : CS is an unknown command...
I do absolutely want to use aliases in my batch program, but I do not want to modify my Path nor my Reg, because it is just to use in the Batch itself. I want to find a solution, but I need any idea. Please if some one can help me with an example, it would be very useful.
EDIT
You cannot run a doskey macro from a batch program.
If you just want to call a Batch file via another name, then just define another Batch file (with the second name) that call the first one. For example
CS.bat file may have this line:
#call smile.bat %*
then, in the first Batch file:
call CS
or
call CS arg1
If this is enough for you, then you may even create the alias Batch file inside the first Batch file this way:
echo #call smile.bat %%*> CS.bat
I hope it helps...
Related
I have a text file with lots of commands in it and I want to sent those commands to a software called thermocal. It is a console application. I found the command below, but it doesn't work for me.
Do I need to put this .exe file in the same folder of the batch file to make it work or any thing else?
type somefile.txt | Thermocal.exe
Batch scripts can be considered as a collection of lines you could also type in a command line prompt one after another. With respect to this it might be helpful for you, to play with cmd in order to get a feeling for what is happening.
About starting thermocal: Assuming thermocal is not part of PATH then the batch file either needs to change the current directory to the one with termocal.exe. Alternatively you might be able to call thermocal.exe with adding a path like C:\ProgramFiles\Thermocal\thermocal.exe . Play with cmd to find out, what works and what doesn't
When you are able to start thermocal from the command line prompt window, you can start experimenting with the call. You will probably end of with something like this in your command line window:
C:\ProgramFiles\Thermocal> thermocal argument1 argument 2
If this works, you can start with batch programming :)
Assuming your arguments are stored in somefile.txt like this:
argument1 argument 2
TYPE does nothing more than printing a file:
TYPE somefile.txt
Now you need to use the result of the output as command line arguments:
for /f %%i in ('type somefile.txt') do (thermocal.exe %%i)
I am trying to execute a shell command or batch file in LiveCode, however, for reasons unknown, it is not working. I would like to use another intermediate program to execute the batch file that records the output to a text file and then read that output with LiveCode as a workaround. What is a simple way to create an executable that can process a batch file?
There is not really any relevant code to share other than
put "test.bat" into tCommand
put shell (tCommand) into fld "output"
The following script works in LiveCode 6.7.6:
set the hideConsoleWindows to true
put shell("C:\test.bat")
My bat file contains
#echo off
echo 'test'
pause
and the value returned by shell() is
'test'
Press any key to continue . . .
The last character of the value returned is a linefeed.
Perhaps you should try to reproduce this simple test.
OK, so I've never written a batch file before, but I have now got to the point where I need a batch file but as far as I'm aware it's going to be quite complex. So, basically this is what I need to do:
I need a batch file that will ask the user a few questions and then use their answers to complete a command to be run in the cmd.exe in Windows.
The command for my machine is as follows:
csvde -f C:\output -d "cn=Users,dc=test,dc=local" -r "(&(objectClass=user)(objectCategory=person))" -l "givenName, sn, objectGUID"
So I need a batch file that would ask the customer the info to go in the fields of the "dc=test" and the "dc=local" and then execute the finished command.
Any sort of help would be excellent, Thanks in advance.
:testlp
(set test=)
set /p test="Please enter test value "
if not defined test goto testlp
then use dc=%test% rather than dc=test
Leave you to figure out how to input local all by yourself...
I need to create a batch file which will run a program (which has been created in C#.Net) and also take a path of a text file as an input.
Not quite sure, how to achieve this.
So far, I have the below command working,
C:\>Folder Path to executable>xxxx.exe -console
-console is my predefined command argument to run this program in console mode.
The part until running the program from the console, with -console, works perfectly fine with a hard coded file path. However, I want to give the functionality to the user to give the file path as they want and create a batch file for the same command. Everytime user can update the batch file with new text file path and simply run it.
Thanks,
Are you just wanting to use the -console parameter? Are there any other parameters you wanted to pass in?
If wanting just what you have in your snippet, Save the following into a batch file. (e.g. StartMyProgram.bat)
start "C:\Folder path to executable\xxxx.exe" -console
See start /? for help and more options.
You need to add %~1 to your script: C:\Path\to\executable\xxxx.exe -console %~1
Now you can call it like this: StartMyApp.cmd C:\Docs\readme.txt
%~1 contains the full path of the text-file. You could also ensure that only text-files are passed to your application:
if "%~x1"==".txt" (
C:\Path\to\executable\xxxx.exe -console %~1
) else (
echo Not a textfile! & pause
)
I need to pass argument from wsf file to bat file to windows command script.
In wsf file I have:
Shell.Run("Something.bat ",&varparam,1,true)
In Something.bat:
sftp.exe testcommand.cmd %1
In testcommand.cmd:
open user#address
put %1
But .cmd file does not get access to the parameter value. How can I get this to work?
In order to pass values into a batch you can use call
Try this:
CALL Something.bat %varparam%
And I think part of your problem is that you are trying to pass values into a command file that is already part of a separate string.
You could get this to work by haveing your Something.bat create your testcommand file.
Something.bat:
echo open user#address testcommand.bat
echo put %1 >> testcommand.bat
sftp.exe -b testcommand.bat
It's not perfect but I'm pretty sure the syntax of
sftp.exe testcommand.cmd %variable%
is your problem.