New
#1
Help Automatating CMD Commands
I need help making a CMD script that will...
Open a certain directory
clear the screen
run a command
and then it must stay open
how would i do this?
I need help making a CMD script that will...
Open a certain directory
clear the screen
run a command
and then it must stay open
how would i do this?
Hello Pedro,
You could use this in a .bat or .cmd file to do so. CLS will clear the screen in the command prompt. Pause will leave the command prompt open until you press a key to close it.
Hope this helps, :)Code:cd "full path of directory" CLS your command pause
Shawn
You can make a batch file
Cd (directory)
Start cmd.exe
This will open a new command prompt in the directory.
i got it anyway after a bit of fiddeling.
how would i make a batch file that detects a usb flash driveCode:echo off cd C:\android-sdk-windows\platform-tools cls adb devices echo off ping 1.0.0.0 -n 1 -w 5000 >NUL
prompts me to copy files
copies files
reports back
and then closes
The adb app does not require the cd line and you might like pause better than ping... or not.
Code:echo off cls C:\android-sdk-windows\platform-tools\adb.exe devices pause
...detect a usb drive via batch file?
Are you wanting this batch file to run all of the time? ...always watching for a usb drive?
Will it always be the same usb drive that this batch file is looking for?
Ok i got it. I made this yesterday and it is quite complicated...
I will post the batch later for viewing purposes.
How would i make a batch file to ask the user for his username,drive lettrs etc. Then it would make a backup of the above file.it would then modify certain lines in the above files and replace them with the inputed username etc
Helping you might be simpler if you would detail what your plans are. I can only assume that you want to copy files from a usb stick to a user's "my doc..." area.
You could also just use the variable %username% which will return the name of the person currently logged on.Code:echo off set /p SomeName= echo %SomeName% pause
Be aware that people can change their username.Code:echo off echo %username% pause
I can be logged on as Fred and my files are under C:\Users\Bob\...
The variable %username% will return Fred...
...but you might want Bob for the path info.
You might find this code more useful:
Also be aware that some usernames have spaces in them:Code:echo off echo %homepath% pause
C:\Users\Tony the Tiger\...
Which means that you should put quotation marks around the path even if you don't need them for most users.
Code:echo %SomeName% > test.bat echo SomeInfo >> test.bat
ok so this is the long version
i am trying to make a batch file to backup all the files on my phone to my documents - i have finished this bit, tested and all is working
i want to publicate this batch so everyone can use it.That means making a 'setup.cmd' that will edit the actual backup batch to suit the users needs. the %username% command you suggested will be used to determin the actual username, but i need a way for the user to specify where his internal sdcard and external sdcard are and adjusting the file accordinly. i will upload the file so you can view it
Ok i done it now and will publish tomorow. I am on my phone so i havnt got the file here.this is my first batch i make and it turned out to be 3500+words so i started big.now my phone is safely backed up. I still need a way to access the system folder for complete backup
'sleep' is not recognized as an internal or external command, operable program or batch file.
I would use %homepath% instead of %username%.
Using dates for the folders is good - but I would create a path more like:
...\year\month\day-time
or
...\year-month-day-time
Those folder structures will sort better.
I do not want to discourage you from learning/using command line batch files, but if you are going to be giving this to others, you might want to learn a scripting language like AutoHotKey or AutoIt.