I cannot execute command line command on Windows 2003 server.
Below is the path which i put in notepad and save it as .bat and RUN it doesnt help.
D:\Program Files(x86)\PH\Check This 7.11\ASD\ABC>sm -reportlic > D:\srini\test1.txt
Above command helps me to execute the command from dos prompt and save results in txt file to D:\ drive at mentioned path.
But cant create a batch file to execute the same.
Please help any assistance will be appreciated.
Regards,
Sri
You need to either change to the proper drive and folder to execute sm first, or call it directly using a full path. In either case, you need to quote the path because it contains spaces.
Changing drive and directory first:
cd /d "D:\Program Files(x86)\PH\Check This 7.11\ASD\ABC"
sm -reportlic > D:\srini\test1.txt
Using a full path:
"D:\Program Files(x86)\PH\Check This 7.11\ASD\ABC>sm" -reportlic > D:\srini\test1.txt
Related
I'm creating a batch file on my desktop which has a simple code:
%SystemRoot%\system32\cmd.exe
This will open up Command Prompt.
Then I need to copy paste following code into the command prompt.
for /r "Z:\QCQA\Main QCQA Files\QA System Files\Nonconformance\Non-Conformance Reports\" %i in (NCR*.pdf) do copy "%~fi" "Z:\QCQA\Main QCQA Files\QA System Files\Nonconformance\NCR Log Tracking\PDF Destination from DOS\" /Y
The above command simply copies and pastes PDFs from one directory to another directory.
Is there a way to write the entire thing into a batch file?
Desired output is:
A Desktop Icon of a BAT File.
Double clicking on it will do two things: Open up Command Prompt and Executes the Copy command.
Closes the Command Prompt once done
Once that's done, I can simply use Windows Task Scheduler to run this Bat file everyday at 5:00 AM.
All the helps are appreciated. Thank You.
Create a batch file on the desktop and use the following code...
#echo off
for /r "Z:\QCQA\Main QCQA Files\QA System Files\Nonconformance\Non-Conformance Reports\" %%i in (NCR*.pdf) do (
copy "%%i" "Z:\QCQA\Main QCQA Files\QA System Files\Nonconformance\NCR Log Tracking\PDF Destination from DOS\" /Y
)
Double Click on the batch file anytime you want to run it.
That's it! =)
I want to create a batch file that a user can run ... in the batch file I want to run an exe with one argument.
Here is what I have today:
#echo off
c:\
cd "C:\Program Files (x86)\App Location\App34\"
start HelperSetup.exe -arg
When I run that it opens up the cmd window and says the path cannot be found but i know for 100% it is the correct path.
I have tried to also pass in the string in a one line but no joy
"C:\Program Files(x86)\App Location\App34\HelperSetup.exe -arg"
I have tried to also pass in the string in a one line but no joy
When you want to also pass in the string in a one line you need to set the closing quote at the end of the path like this:
"C:\Program Files(x86)\App Location\App34\HelperSetup.exe" -arg
A much simpler approach for your batch script is to use the following command sequence
start /d "C:\Program Files (x86)\App Location\App34\" HelperSetup.exe -arg
This way, you don't need to change the drive and the cd command at all.
I want to start a batch file in a certain location. I tried start /d C:\Windows C:\Windows\branding\readWin..bat The batch file which launches this in on my desktop. Any way to do this?
Thanks.
I'm not sure exactly what you mean. You shouldn't need to change the current/start-in directory before invoking a script. If that script needs to define its working directory it should do so within.
If that's the case then just enter the full or relative batch file name:
"C:\Windows\branding\readWin..bat"
If the batch file you're wanting to invoke does not define its own current directory and you feel it's necessary then you could be sure by defining it yourself first:
CD /D "C:\Windows"
Or:
PushD "C:\Windows"
After that just run your batch file using its full or relative path as previously mentioned.
Are you running this from command prompt?
start /d "path" file.bat
The quotes around the file path are important, and just the file name follows the path.
I need a batch file which will do the following:
1. Open CMD and navigate to a location C:/Users/...../program.exe
2. Run the program.exe with an additional command to point it to a config file:
e.g. "program.exe C:/Users/..../configFile.bgi"
How can I do this?
I tried this but with no luck:
start "C:\Users\Ben\Desktop\BGInfo\bginfo.exe C:\Users\Ben\Desktop\BGInfo\dc_bginfo.bgi"
pause
Update
I've used the solution provided by Ganesh (below) and came up with this:
cd C:\Users\Ben\Desktop\BGInfo\
bginfo.exe C:\Users\Ben\Desktop\BGInfo\dc_bginfo.bgi
I've tested it on a local machine (changing the directories) but on the server (with the directory above) it does not work...
The folder directory with batch file:
The error
in batch file abc.bat
cd c:\user\ben_dchost\documents\
executible.exe -flag1 -flag2 -flag3
I am assuming that your executible.exe is present in c:\user\ben_dchost\documents\
I am also assuming that the parameters it takes are -flag1 -flag2 -flag3
Edited:
For the command you say you want to execute, do:
cd C:\Users\Ben\Desktop\BGInfo\
bginfo.exe dc_bginfo.bgi
pause
Hope this helps
You can use
start "" "%USERPROFILE%\Desktop\BGInfo\bginfo.exe" "%USERPROFILE%\Desktop\BGInfo\dc_bginfo.bgi"
or
start "" /D "%USERPROFILE%\Desktop\BGInfo" bginfo.exe dc_bginfo.bgi
or
"%USERPROFILE%\Desktop\BGInfo\bginfo.exe" "%USERPROFILE%\Desktop\BGInfo\dc_bginfo.bgi"
or
cd /D "%USERPROFILE%\Desktop\BGInfo"
bginfo.exe dc_bginfo.bgi
Help on commands start and cd is output by executing in a command prompt window help start or start /? and help cd or cd /?.
But I do not understand why you need a batch file at all for starting the application with the additional parameter. Create a shortcut (*.lnk) on your desktop for this application. Then right click on the shortcut, left click on Properties and append after a space character "%USERPROFILE%\Desktop\BGInfo\dc_bginfo.bgi" as parameter.
Found another solution for the same. It will be more helpful.
START C:\"Program Files (x86)"\Test\"Test Automation"\finger.exe ConfigFile="C:\Users\PCName\Desktop\Automation\Documents\Validation_ZoneWise_Default.finger.Config"
finger.exe is a parent program that is calling config solution.
Note: if your path folder name consists of spaces, then do not forget to add "".
I have the following code in the batch-file:
#echo on
regedit.exe /S abc.reg
If I run it, I get an error.
I searched the google for this and found nothing. Can someone help me please?
I tried:
- removing /S (the I can read (of course) the errormessage
- Run the file as administrator (I'm admin per default)
I am using windows 8.
The erros message: "Cannot import C:\users....abc.reg". Error opening the file. There may be a disk or a file system error.
Both Files are in the same folder.
The problem was, that I handled the %~dp0 in a false way. %~dp0 stands for the default path, but you don't have to set a backslash after it!
If you want to run a .reg file in the same folder as the .bat file, just write it like this:
#echo on
REGEDIT /S "%~dp0ABC.reg"
This will run the file ABC.reg in the same folder.
If you wan't to run something in a subfolder, you have to do it like this:
#echo on
REGEDIT /S "%~dp0SUBFOLDER\ABC.reg"
The brackets ("") are only needed, if there are whitespaces in the pathname.
Much easier way is run it as a Scheduled task.
In this way you can get your batch file to run as admin without annoying password prompts.
For more valuable information, please read here...
http://forums.whirlpool.net.au/archive/2037875
http://social.technet.microsoft.com/Forums/systemcenter/en-US/be854b0a-5d41-4b03-9a84-8fe79732f33c/run-bat-file-to-call-reg-file-in-sccm?forum=configmgrswdist
http://www.myitforum.com/articles/1/view.asp?id=12036
Right click on aix2_mm.bat and select "Run As Administrator", you will get a full screen UAC prompt that you must agree with, then it will work.
If you don't see 'Run As Administrator' as an option, hold the shift key prior to right clicking.
and it wouldn't hurt to make your batch more portable. The %~dp0 parameter will expand to the full path to ABC.reg if it's in the same folder as the .bat file.
#echo on
regedit.exe /S "%~dp0abc.reg"
Be careful the working directory
My bat file always has the code on first line
cd /d %~dp0
It can safely change current directory to your bat file directory