I want to copy a file from sharing folder to another using cmd command ".bat file"
the below code works normally with most files except MS Access files the "accde" extension so, please advise.
MKDIR "\\192.168.0.110\Attendance Sheet\JTA\events\events_media\SysFile"
XCopy /y/z "\\192.168.0.110\Attendance Sheet\JTA\events\events_media\db.accde"
"\\192.168.0.110\Attendance Sheet\JTA\events\events_media\SysFile"
Run this code to have the command execute in the background so that you can continue to work from the command line while it is running:
start /min xcopy /y /z "sourcefile" "destination"
Actually, the command is running in a minimized window of it's own - you can see it popping up in the taskbar. But from a user's perspective it's the same as running "in the background".
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 have a batch that is like this
#echo off
SET workspace="C:\yii2"
SET deploy_directory="C:\deployment"
SET source_file="C:\deployment\yii2"
SET destination_file="C:\deployment\deployment.zip"
cd "%source_file%"
start /wait update composer
start /wait xcopy "%workspace%" "%source_file%" /s /h /f
cd "%deploy_directory%"
start /wait zipjs.bat zipItem -source "%source_file%" -destination "%destination_file%" -keep yes -force no
pause
The bat file can anywhere be in the system.. So I write something like this.. Currently this is not working .. when it runs and change the directory the command prompt pops out and it does not process the next code.. Is there a silent way to change directory without interruption and will process the next command?
main goal is that to run composer update in the target path. Would appreciate also to explain what's happening here.
Pseudo:
1.) go to workspace path to update composer
2.) Copy workspace to a certain path with my zip bat
3.) change to that directory
4.) Run zipping bat
Edit: Added more steps
start starts a new command window. You just want to change the working directory of the command window that is going to run update. So don't use start for the cd bit:
cd "%source_file%"
start /wait update composer
One reason to use start is to run another batch file without terminating the current one. This works because the second batch file is run in a new command shell (and window). Usually, a better option is to use call, which runs the second batch file in the current command shell / window but doesn't terminate the current shell. In your case, since update is also a batch file, you can use call. So your script now looks like this:
cd "%source_file%"
call update composer
i need to create a file as if i was the browser for a qa test. I figure if i copy and rename cmd.exe i can execute commands and the process will be the browser and complete my criteria for the test. i need to do this via a batch script. Below is my attempt at getting something to run as if it was from the browser.
my issue is the command is not creating the file in the directory like it should be. The dir command shows the directory as being empty even though as far as i can tell, everything worked correctly. There are no error logs or alerts. why can i not copy this file?
thanks!
copy C:\Windows\System32\cmd.exe %userprofile%\AppData\Roaming\firefox.exe
md %userprofile%\AppData\Local\test12
start %userprofile%\AppData\Roaming\firefox.exe \C copy C:\Windows\System32\cmd.exe %userprofile%\AppData\Local\test12\Test12.exe
dir %userprofile%\AppData\Local\test12\
If you try to use /K in stead of \C (the slash is wrong here) the cmd.exe (firefox.exe) will show you any errors that occured :
This works fine here:
start /WAIT %userprofile%\AppData\Roaming\firefox.exe /K copy C:\Windows\System32\cmd.exe %userprofile%\AppData\Local\test12\Test12.exe
I want to write a batch file that will do following things in given order:
Open cmd
Run cmd command cd c:\Program files\IIS Express
Run cmd command iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0
Open Internet Explorer 8 with URL= http://localhost:8088/default.aspx
Note: The cmd window should not be closed after executing the commands.
I tried start cmd.exe /k "cd\ & cd ProgramFiles\IIS Express", but it is not solving my purpose.
So, make an actual batch file: open up notepad, type the commands you want to run, and save as a .bat file. Then double click the .bat file to run it.
Try something like this for a start:
c:\
cd c:\Program files\IIS Express
start iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0
start http://localhost:8088/default.aspx
pause
I think the correct syntax is:
cmd /k "cd c:\<folder name>"
This fixes some issues with Blorgbeard's answer (but is untested):
#echo off
cd /d "c:\Program files\IIS Express"
start "" iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0
timeout 10
start http://localhost:8088/default.aspx
pause
cmd /c "command" syntax works well. Also, if you want to include an executable that contains a space in the path, you will need two sets of quotes.
cmd /c ""path to executable""
and if your executable needs a file input with a space in the path a another set
cmd /c ""path to executable" -f "path to file""
#echo off
title Command Executer
color 1b
echo Command Executer by: YourNameHere
echo #################################
: execute
echo Please Type A Command Here:
set /p cmd=Command:
%cmd%
goto execute
start cmd /k "your cmd command1"
start cmd /k "your cmd command2"
It works in Windows server2012 while I use these command in one batch file.
cmd /k cd c:\
is the right answer
I was trying to run a couple of batch files parallely at startup, if a condition was true.
For this I made a parent batch file which should have checked for the condition and invoke the other child batch files if the condition was true.
I tried to achieve it via START but it gave me an empty black command prompt running in the directory of children batch files, instead of running the children batch files themselves
The thing which worked for me was by using a combination of START and CALL
As an example
condition ...
start call "C:\Users\Amd\conn\wsl_setup - conn1.bat"
start call "C:\Users\Amd\conn\wsl_setup - conn2.bat"
start call "C:\Users\Amd\conn\wsl_setup - conn3.bat"
I know DOS and cmd prompt DOES NOT LIKE spaces in folder names. Your code starts with
cd c:\Program files\IIS Express
and it's trying to go to c:\Program in stead of C:\"Program Files"
Change the folder name and *.exe name. Hope this helps
I tried to run multi-windows commands inside one opened window from a batch file.
I want the opened command window to perform two things in sequence:
Switch volume
Direct to a directory in that volume.
Here's what I wrote:
start cmd /k C: && cd 'C:\Program Files (x86)\aaa\'
However, this only switches volume. The second thing is not executed.
Can anyone please show me the way?
Well, you have at least 2 options...:
1st, make sure your && is passed to new cmd...
start cmd /k "C: && CD c:\temp"
2nd, use /d switch on cd to "get there" in one step...
start cmd /k cd /d c:\temp
KR
Bartek
What don't you just open your cmd at the needed directory? Like^
start /dc:\temp cmd
If you want to change directory to another drive you can use
cd /d C:\
but if your changing directory within the same drive you shouldn't need to switch drives, just change to that directory:
cd "C:\Program Files (x86)\aaa"
Remember to put quotes around paths with spaces, possibly why your command didn't work earlier.
Also, you shouldn't really need start and cmd. What you doing doesn't really need to be threaded as such. If it's a batch file you can just use pause at the end instead of using cmd /k.
Your complete batch file would then look like this:
cd "C:\Program Files (x86)\aaa"
pause >nul
or using cmd /k for one line (in case of command line use):
cmd /k cd "C:\Program Files (x86)\aaa"
Hope this helps!