FAQ Database Discussion Community


I can't connect and upload to FTP by command line

windows,batch-file,cmd,ftp,automation
I can't succeed to connect and upload files to some ftp by BATCH file I made. Also, I want to upload all files from this local directory. Please your help! Thanks. The code: @echo off echo user username>> ftpcmd.dat echo pass>> ftpcmd.dat echo cd /public_html/reports/>> ftpcmd.dat echo mput C:\automation\tests\HtmlReporter\*>> ftpcmd.dat...

bat file script to check if string contains other string

windows,batch-file,cmd
I need to write a batch file that will check if a variable contains specific value. I tried to do the following: If "%%a"=="%%a:%pattern%" ( echo Yes ) else ( echo No ) input example: %%a="bob binson" %patern%="binson" I never get Yes printed! can anyone please tell what i missed...

Runas a certain xls file

excel,batch-file,cmd,runas
I need to write a batch script which opens a certain xls file on behalf of another user account. runas separately works OK: runas /profile /user:username "C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE" excel connector is also OK: "C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE /r C:\fol der\file.xls" but together it's not: runas /profile /user:username "C:\Program...

Switch back to PowerShell mode after switching to cmd mode

windows,powershell,cmd,windows-8.1
From PowerShell, we can run cmd to switch to a command prompt. From there, how can we switch back to PowerShell. For instance... PS> cmd C:\temp> echo I am in command mode. I am in command mode. C:\temp> echo How do I switch back to PowerShell mode? How do I...

Recursive check files and perform zip if a particular file type exists

windows,powershell,batch-file,recursion,cmd
My Problem statement: Main Folder -SubFolder1 --1.jpg --2.jpg -SUbFolder2 --Subsubfolder ---1.jpg ---2.jpg I have this main folder which has subdirectories and at the last subdirectory, there are images. Now, what I wish to achieve is recursively check if image file(s) exists in a subdirectory If it does, zip all the...

how to make batch wait for multiple subprocesses

batch-file,cmd,wait
I have this batch file: SET WINRAR="C:\Program Files (x86)\WinRAR" start "" %WINRAR%\WinRAR.exe a -u -m5 "Group 1.rar" "Group 1" "Group 1" start "" %WINRAR%\WinRAR.exe a -u -m5 "Group 2.rar" "Group 2" "Group 2" start "" %WINRAR%\WinRAR.exe a -u -m5 "Group 3.rar" "Group 3" "Group 3" start "" "D:\" I want...

Wildcard (*) in the path don't work while copying from cmd [closed]

windows,cmd,path
There is a file (abc.txt) in a folder- C:\vackwrk\24may\abc.txt and i want to copy that file to another folder using cmd- G:\work\ I use copy C:\vackwrk\24may\abc.txt G:\work\ this work , but when i am using wildcard it don't work copy C:\vackwrk\*\abc.txt G:\work\ this time output is - The filename ,...

cmd/DOS window opens with GUI created with py2exe

python,user-interface,cmd,py2exe,pyqt5
I have created a GUI using PyQt5. The aim of the GUI is to pass some input data (images, shapefiles etc) and to use them in softwares (GIS mostly). To launch the GIS I use the subprocess.Popen command line. I have used py2exe to create my app and my problem...

cmd append to file > extra space in the end

windows,cmd
set NUMBER=0 echo 3.3.3.%NUMBER% > "file.txt" after running this command the content of file.txt is 3.3.3.0 with extra space after the 0 I would like to remove the extra space, how this can be done? EDIT I following the answer of bgoldst the extra space is gone, however now I...

execute method in cmd without main function

java,cmd,main
I need to execute a method in .java or .class but this class doesn't have a main function (I can't use main function because it has no return value) I must execute this method in cmd , Is there any way to resolve this problem ?

npm install error not installing BrowserSync package

node.js,cmd,npm,command-prompt,browser-sync
Trying to install BrowserSync I've followed the steps to install the package through the command line, installed node.js and then I went on to install npm through the command line. Now when I try to install browser-sync with the following line npm install -g browser-sync you will see it is...

Windows User Environment Variable vs System Environment Variable

windows,powershell,cmd,environment-variables
In Windows, is there any shell/Powershell command to list User Environment Variable and System Environment Variable separately. If I do - SET TEMP Windows displays the User Environment Variable instead of System variable for Temp. I am looking for shell command/switch to display these variables separately....

Windows script batch to copy files from different folders to other folders

windows,batch-file,cmd
The easiest way to explain the problem is by an example. I want to do something like this: file x in /path_1/A/x copy in /path_2/A/ file x in /path_1/B/x copy in /path_2/B/ ... ... file x in /path_1/Z/x copy in /path_2/Z/ From command line with a script in Windows....

PYTHON subprocess cmd.exe closes after first command

python,cmd,subprocess,stdout,stdin
I am working on a python program which implements the cmd window. I am using subproccess with PIPE. If for example i write "dir" (by stdout), I use communicate() in order to get the response from the cmd and it does work. The problem is that in a while True...

Batch md command

batch-file,cmd
I'm trying to copy contents of a cd to x86 of my computer. When I run my script it says "A subdirectory or file \Navel already exists". When I navigate to my x86 folder my file isnt there. How do i fix this. cd %ProgramFiles(x86)%\ md \Navel pause ...

Simple .BAT file rename issue

windows,batch-file,cmd,rename
Okay, so here's my issue. I have a program (program1) that when run looks for an INI file that has info about the user stored in it (userinfo.ini). The program does not support multiple users, so my idea is to have two INI files, one for user1 and another for...

cmd parallel execution and termination

windows,bash,cmd
I have the following bash script: node ./build.js & node ./server.js It creates two nodejs processes and executes them in parallel. When I press Ctrl-C, both processes are terminated. I'm trying to do the same with Windows cmd shell. Here's what I have currently: start /B node ./build.js & node...

How to check and correct user input when he omit the extension .exe to kill the process?

batch-file,cmd
I have this batch to kill some process typed of course by the user and it works 5/5 when the user for example typed Calc.exe with the extension, but my issue now is to improve this batch in order to add automatically with this program if the user has omitted...

Console colorizing AWK script does not work on cmd.exe

windows,awk,cmd,console
I wrote an AWK script, so that while launching my python scripts, stout is being colorized. Fine, it works, but only while using cygwin. For some reason I have to use win7 cmd.exe. I installed gawk for win but it does not work: python script.py | awk -f colorize.awk here...

How to Continue a Command after Error in Batch Files?

batch-file,cmd
So here's the code cd C:\Users\%USERNAME% G: md backup cd backup c: xcopy *.* /e /h g: pause While the Xcopy is trying to copy certain files it runs into an error, and stops copying, how do I force it to skip the current file and copy the next one?...

Parsing the text file line-by-line using batch script (batch file)

windows,batch-file,scripting,cmd
So, I am programming in the batch script and I came across this issue. The following code will take yourwords.txt file and parse it. The existedWord variable will have the last word of the text file. So, everytime when I run this program it will only compare the user's input...

Execute multiple command lines with output

c#,cmd,output
I want to perform some command lines to display the result after each input. Process p = new Process(); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "cmd.exe"; info.RedirectStandardInput = true; info.UseShellExecute = false; p.StartInfo = info; p.Start(); using (StreamWriter sw = p.StandardInput) { if (sw.BaseStream.CanWrite) { sw.WriteLine("ftp"); //output sw.WriteLine("open ftp.server.com");...

Running Java Parameters with Spaces In Them

java,cmd
I'm using batch and I'm trying to run a java application with multiple parameters. However, since my directories have spaces in them, java doesn't recognise it. (I'm attempting to run minecraft) java -Djava.library.path="c:\users\user\documents\visual studio 2013\Projects\launch2\launch2\bin\Debug\libs\" -cp "c:\users\user\documents\visual studio 2013\Projects\launch2\launch2\bin\Debug\versions\1.7.2\1.7.2.jar"; And so on and so forth... The problem here is this...

Batch file to open multiple instances of cmd and run Ruby script in each instance

ruby,windows,batch-file,cmd,watir-webdriver
I'm trying to open multiple instances of cmd up which each run a ruby script at the same time. For background into the scripts, each of these ruby scripts run watir-webdriver and spawn new browser instances. All of this should happen instantaneously. Here's what I've tried: start cmd /k cd...

cmd read content from file and removing extra space in the end

cmd
In a batch file I am reading the content of a file to version parameter set /p version=<"\\10.10.20.13\Versions Control\File.txt" in File.txt the value is This is a text with an extra space in the end How can I read the content of File.txt and trim the extra space after the...

Reading file made by cmd, results in 3 weird symbols

c++,file,c++11,visual-c++,cmd
Im using this piece of code to read a file to a string, and its working perfectly with files manually made in notepad, notepad++ or other text editors: std::string utils::readFile(std::string file) { std::ifstream t(file); std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>()); return str; } When I create a file via notepad (or any other...

searching a specific word from a list of words in batch file

batch-file,cmd,scripting
I have a %list% variable which has words (see the code) and I want to search a word which ends with letter 'Y' (ignoring the case-sensitive) and which starts with the last letter of user's input. User input would be any valid word. Once I find that specific word then...

Cmd doing weird things when i use ftp

batch-file,cmd,ftp
Here i have my batch script @echo on if not [%1]==[] GOTO :copy_file if [%1]==[] GOTO :open_folder :copy_file echo open 95.105.195.45 > temp.txt echo nope >> temp.txt echo nope >> temp.txt echo nope >> temp.txt echo nope >> temp.txt echo nope >> temp.txt echo nope >> temp.txt echo nope >>...

Alert on operation completion in windows cmd

windows,cmd,command-prompt
Using windows cmd I have to put large programs on compilation which take large amount of time. Everytime to know whether operation is complete or not I have to check cmd again and again. I want to know whether there is way by which I can make changes to cmd...

mysqldump with date and time in backup file name on windows

windows,cmd,filenames,mysqldump
I am unix man, and I really don't like work on windows. I am asking You for help. I am trying to make regular backups of mysql database in microsoft windows cmd. Here is my current script for that: C:\xampp\mysql\mysqldump.exe -hlocalhost -uroot -ppass stp > V:\backup_3.2.2.6__%date:/=%.sql I would like to...

How to batch delete specific folder in user's share

windows,batch-file,cmd
I'm trying to devise a way to batch delete a specific folder within many user backup folders. What I have is a server that stores user backups by username, within a parent directory called Users. The issue is when the backup script was created it was configured for XP paths,...

Run sql script using batch file from command prompt

mysql,sql,batch-file,cmd
D: cd Tools/MySQL5/bin mysql -u root mysql use xyz; source C:/Users/abc/Desktop/xyz.sql; \q When I run the above lines in command prompt it works fine but when I save it as a batch file and run the file it connects to mysql but doesn't perform the sql scripts....

Coding of Admin-Guest login section in an OS

linux,authentication,cmd,linux-kernel,operating-system
I developed an authentication algorithm for user authentication as part of my masters thesis and implemented it in PHP. I intend to know how can I implement the algorithm for operating system login, in which language (for linux)? also where the code will reside because it will not be click...

PowerShell allow to use wildcard while copying file but cmd don't allow , why?

windows,powershell,batch-file,cmd
Previously i was using cmd to copy file (abc.txt) from C:\vackwrk\24may\abc.txt to G:\work\ and command i used in cmd was copy C:\vackwrk\*\abc.txt G:\work\ it didn't work but when i use PowerShell it works (file copied to another folder) PS C:\Windows\system32> copy C:\vackwrk\*\abc.txt G:\work\ (Wildcard (*) in the path don't work...

Run a batch file at folder's context menu

windows,batch-file,cmd,registry,explorer
I'd like to run this batch file (setenv.cmd) when I right click on any folder: @echo off SET CPLUS_INCLUDE_PATH=C:\mingw32\include;C:\mingw32\lib\gcc\mingw32\4.9.2\include; SET PATH=%PATH%;C:\Archivos de programa\7-Zip;C:\Archivos de programa\WinRAR;C:\usr\bin;C:\msys\1.0\bin;C:\gtk2\bin SET PKG_CONFIG_PATH=C:\gtk2\lib\pkgconfig;C:\usr\lib\pkgconfig @echo on I setuped my registry from this page, with the "prompt here". My question is how to open the console window from...

Extracting specific registry key from REG QUERY based on search string

windows,for-loop,cmd
I am trying to extract the key value of a registry entry. I only want the key which I have been trying to concatenate using FOR /F, however had no luck. Eg: the command REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s /f chrome returns HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{157F97DF-A001-36FB-A90C-55949FA130CA} DisplayName REG_SZ Google Chrome End of search: 1...

How to stop an input-waiting Windows batch process in Java?

java,windows,batch-file,cmd
I have a Windows batch file simple.bat which produces some output in stdin, and ends with a pause. I want to run this batch file and then process the output in my Java code. // create a Java process with simple.bat Process p = Runtime.getRuntime().exec("cmd /c simple.bat"); // get the...

How to extract a string from the first line of a file using batch?

windows,batch-file,cmd,batch-processing
I have these files that contain a name in the first line I wish to extract. All the methods I have approach either result in error or give me nothing. An example file can be found here: https://www.dropbox.com/s/0kcgj8vr3wii33s/FORS2.2011-10-23T23_59_20.355_out.fits?dl=0 I wish to extract "PN-G013.3+01.1", which lies on the first line (column...

How to format dir command in cmd for XP and Win 2000

windows,cmd,windows-xp,windows-2000
When I use dir command in win XP it returns all kind of info: Volume in drive C is OSDisk Volume Serial Number is AEF7-B35F Directory of C:\Users\bd250124\Desktop\test 06/11/2015 12:14 PM <DIR> . 06/11/2015 12:14 PM <DIR> .. 06/11/2015 12:14 PM 10 test01.txt 06/11/2015 12:13 PM 0 test02.txt 2 File(s)...

Scan from printer using node js

node.js,cmd
How can I use nodejs to tell the printer(& scanner) to start scanning, I tried to use exec = require('child_process').exec to execute some command prompt, but i don't how to tell scanner to start scanning, I will accept command prompt answer.

Batch File get Specific IP into Variable

cmd,ip,netsh
I am trying to select a specific IP address in a windows batchfile. This line of code works, but gets the wrong IP address: for /f "delims=: tokens=2" %%a in ('ipconfig ^| findstr /R /C:"IPv4 Address"') do (set newip=%%a) If I type this at the command line, it gets a...

execute the NETSH WLAN SHOW ALL command with pauses

batch-file,cmd
I'm creating a batch program of which one function is to show all properties of the wlan, however, when executing the command NETSH WLAN SHOW ALL all output goes by so fast half of it can't be read. I was wondering if there is a way of adding pauses during...

How to pass parameter ending with “!” to another bat file?

windows,batch-file,parameters,cmd,parameter-passing
I have two bat files and i need to pass three parameter from one bat file to the other. However if the parameter ends in an "!" the parameter is not receieved caller.bat impl.bat param1 param2! param3 impl.bat echo %1 echo %2 echo %3 Expected Result after running caller.bat: param1...

Need to run .exe file for 7 seconds and then kill the exe while performing input and output in text files

windows,batch-file,cmd
I want to create a batch file which runs a program for 7 seconds, irrespective of the completion of execution of the other program. I also want that the program should take input and save the output in an external file. This is what I tried: start program.exe ping 1.1.1.1...

How can I run “query session” using vb.net?

vb.net,visual-studio-2013,cmd
I would like to get the results from executing "query session" in the cmd.exe and Store them in a string variable using VB.NET. I have been searching for two days now and I cannot get to run the command, I will try to save the result once I get the...

Implementing timed input in batch file. (countdown to a minute)

windows,batch-file,cmd,countdowntimer
I am using windows 8 to write a batch file and I got stuck in implementing the timer in batch file. I want to ask input from the user and give them one minute to type their input. Once the time hit a minute then display message like 'the time...

Runtime.getRuntime().exec gets no results when used from java netbeans

java,r,cmd,netbeans-8
I am working on a Java project, and stuck at a step as it is showing no results. The java code is: public class callPgs { public static void main(String[] args) { // TODO Auto-generated method stub try{ Process p = Runtime.getRuntime().exec("C:/R/R-3.2.0/bin/Rscript.exe C:/R/R-3.2.0/bin/arrayqualityMetrics.R"); int processComplete = p.waitFor(); if (processComplete ==...

Why I am getting different results while executing the following command with cmd and git bash?

java,git,bash,maven,cmd
While I am executing the command below, I have BUILD SUCCESS in git bash and BUILD FAILURE in cmd. Why do I have such a differnce? Do I need to execute this in git bash only or did I miss anything? Thank you. mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 \ -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \...

Replace the part of the path by string in specific file type in a folder

windows,batch-file,cmd
In U:\mtproject\obj\ folder and sub-folders having *.def files. I need to get those file paths and print in the command prompt. but before print I need to replace the U:\mtproject\obj\ part by E:\backupDir\DefBackup\. Here is what I tried and set objdir=U:\mtproject\obj\ set backupdir=E:\backupDir\DefBackup\ for /r %objdir% %%f in (*.def) do...

I cant get the CMD outputs to display in my textbox.

c#,cmd,textbox,user,boolean
Since Local User Group Management doesnt seem to be something I can query in C#, I figured I would do a down and dirty version of what I an trying to accomplish and I need some advice for best practices. THE GOAL: Essentially, I need to determine if the current...

How can i build to a folder that lives one directory down from my current folder

java,cmd,javac,filepath,shortcut
I want to compile to a file that lives in folder src. The build folder lives in the same folder as my src folder. So in CMD i am currently in C:\Programming Projects\Java Sample Projects\src> I want to build to C:\Programming Projects\Java Sample Projects\build> I know i can use the...

ProcessBuilder or Runtime.getRuntime().exec won't complete jar execution

java,xml,xslt,cmd,processbuilder
I have a jar which converts one XML to other XML format using XSLT in Java. The jar copies the output to some folder. It is working absolutely fine when am running it on command prompt but running it via Runtime.getRuntime().exec or ProcessBuilder, doesn't complete the process. Just 25 files...

Disable cmd opening from GUI (PyQt)

python,user-interface,cmd,pyqt,pyqt5
I have a GUI (created with PyQt5 and py2exe). This GUI takes input data (shp, images..) and uses them as parameters in softwares (ie FME). Whenever I launch a task on a software through the GUi, a cmd opens. To launch the softwares, I use subprocess.Popen in my script with...

Storing the value of 'bitsadmin /getstate myDownloadJob into a variable in a batch script

windows,batch-file,cmd
I am having an issue, I am running a job using bitsadmin and I want a more detailed state of the job for the people using it. bitsadmin /getbytestotal myDownloadJob bitsadmin /getbytestransferred myDownloadJob I would like to store the result of this into a variable. I tried parsing it to...

Checkout a complete Subversion tree excluding tags/ and branches/

bash,svn,version-control,cmd,branch
I'm working on a corporate source code tree that contains 100s of Maven sub-projects. Since each sub-project has its own layout of branches/ and tags/ sub-folders, the entire tree is laid out something like this: root/ some/intermediate/dirs/ project1/ branches/ ... tags/ ... trunk/ ... project2/ branches/ ... tags/ ... trunk/...

Copying CMD output to clipboard

c#,winforms,cmd
I'm trying to copy output from a program running out of the CMD prompt to the Windows clipboard. private void button1_Click(object sender, EventArgs e) { /*Relevant Code*/ Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = String.Format("/k cd {0} && backdoor -rt -on...

How to pass a variable into %0 part of batch file with ftp?

windows,batch-file,cmd,ftp
I have a batch file I want to be able to call from the command line like: myBatch.bat testParam That batch file is the following: set sid=%1 C:\Windows\System32\ftp.exe -s:%0 goto done open servername username password get 'FilePath%sid%restoffilepath' targetPath\%sid%MyName.txt bye :done However, I cannot seem to get the FilePath%sid%restoffilepath part to...

How do I run multiple cmd files within a batch?

windows,batch-file,cmd
I've seen multiple posts about issues like this, but I can't find the answer that would fit my example. What I need Within my script I need to start all .cmd-files that are in a spesific folder (not where my script is located). It is 53 .cmd files that does...

Redirect content to a file in ascii encoding

windows,powershell,cmd,less,windows-8.1
We're running lessc from the PowerShell like this: lessc -x style.less > style.min.css Unfortunately, style.min.css file is in unicode whereas we would like it to be in ascii. How can we force that encoding when writing the result to a file from PowerShell? Interestingly, when we run the same command...

'The command line is too long' when linking .obj files in Windows command prompt

windows,maven,dll,cmd,linker
As a last step to my maven build on Windows, it tries to create a dll file by linking around 1500 object files. Looks something like this: cl.exe foo.dll (around 1500 .obj files) (couple of other statically linked libraries) The build fails with just one statement: The command line is...

Win7 Batch File - Moving Subfolders(& Files) to Grand-Parent Directory

batch-file,cmd,merge,move,subdirectories
I have a somewhat complicated problem. I've downloaded an archived website from archive.org using Httrack and now I have thousands of subfolders and files I need to merge before I can rebuild it. I'm trying to write a batch file to solve the problem. But my search results never come...

Batch file to conditionally execute ifortvars.bat

windows,batch-file,cmd,fortran
I am using a make.bat file to compile my Fortran code. To compile using the ifort command, I first need to initialize the compiler by executing ifortvarsbat intel64 command where I had to setup the path variable. This works fine, however, the path keeps increasing in size and says command...

add node to cluster using cmd in windows elasticsearch

windows,elasticsearch,cmd
How can I add nodes to same cluster using cmd in windows? There are commands to do that for linux. Is there a similar thing for windows? I tried searching, but I didn't find anything. (Sorry if this seems really basic, I'm new to this.)

Create batch script to edit host file by network connection

windows,batch-file,cmd,network-programming
I want to use this batch script to add new entries into my host file automatically by using windows batch. I want to edit host file only when i m in office. I want to say like that: if(network name=='OfficeWifi') do changes... @echo off set hostspath=%windir%\System32\drivers\etc\hosts // if(network name=='OfficeWifi') echo...

Command Prompt auto confirm message pop up window

batch-file,cmd
I'm running a batch file that runs a command line, mid way in the command, there is a message pop up where once has to press "OK" in order to continue processing the command. Is there something I can add that would auto confirm this pop up?

adding text after prompt for input

java,input,cmd,prompt
I'm new to Java & I don't even know if what I'm trying to do is actually doable in cmd but I want to know if there's a way to ask the user for an input while displaying something at the right of the input, something like: enter weight: _...

Catch result of process from exe (right click context)

batch-file,command-line,cmd,registry,right-click
I wrote following reg file inorder to delete files/folders securely. Cmd working as expected. But sometimes I would like to see result of it (I do not want to disappare of cmd window) How can I pause / wait / stop before windows disappared "D:\Desktop\_NotUse\SDelete\sdelete.exe -s -p 5 \"%1\"" /pause...

CMD script Malfunctioning

windows,cmd
I have a cmd script that simply runs a windows 7 custom theme-pack (you can download it here.) The file can be downloaded here Whenever I run it, the files malfunctions (read below for a description of the malfunctioning) The file's contents echo off color a title "System Shutdown Manager"...

Self Delete jar from Windows batch file

java,windows,batch-file,jar,cmd
I have a Java application that should update itself by downloading a new version online, and then it should self-delete itself, i already managed the update, now i need to delete the old jar file. Since my app will be running only on windows i thougt that i could use...

Scheduled SQL Server Data Export to CSV using SQLCMD

sql-server-2005,cmd,server,bcp,sqlcmd
This is my command line: sqlcmd -S DEVSERVER\SQLEXPRESS -i c:\SQL_Query.sql -o c:\CSV_Output.csv -s”,” And my sql script: SELECT * FROM dbo.pay The file with this error message: Msg 208, Level 16, State 1, Server DEVSERVER\SQLEXPRESS, Line 1 Invalid object name 'dbo.pay'. ...

Executing 'adb logcat' command using Runtime class

java,android,cmd,logcat
I was trying to get the logcat content into a JTextPane. I used following code hoping it will return the content as String but it freeze and also, doesn't produce an error. Process exec = null; try { exec = Runtime.getRuntime().exec("adb logcat -d"); InputStream errorStream = exec.getErrorStream(); BufferedReader ebr =...

command on specific device

powershell,batch-file,cmd
I am trying to write a batch script, which will always be executed at a specific location (in this case on my USB-Stick), so typically I would use D:, but sometimes the stick has another drive letter. Therefore I am trying to find the device via its name (USB_Stick). I...

Windows CMD Batch: FOR /R with DelayedExpansion

batch-file,for-loop,command-line,cmd,variable-expansion
On my desktop, there is a folder named "test". Inside this folder is two files, "file1.txt" and "file2.txt". Take a look at this simple batch script: @ECHO OFF SET test="C:\Users\Tyler\Desktop\test" ECHO %test% FOR /R %test% %%F IN (*) DO ( ECHO %%F ) As you might expect, it outputs the...

cmd command in c#

c#,mongodb,cmd,system.diagnostics,mongoimport
I want to import a csv file to mongodb by using mongoimport in C#. So I implement this method public bool importCSV(string filepath, string db, string collectionName){ string result=""; try { ProcessStartInfo procStart = new ProcessStartInfo("cmd", "C:/MongoDB/Server/3.0/bin/mongoimport -d " + db + " -c " + collectionName + " --type...

I can't upload a multiple files to FTP by batch script

windows,batch-file,cmd,ftp,automation
I can't succeed to upload a multiple files to some FTP by batch file I made. Also, I want to upload all files from this local directory. The code: ftp -s:"C:\automation\fileup.bat" MYSERVER.COM USERNAME PASSWORD ascii cd "/public_html/reports/" lcd "C:\automation\tests\HtmlReporter" mput * close quit The error: C:\automation>ftp -s:"C:\automation\fileup.bat" MYSERVER.COM Connected to...

How to print iterations per second?

python,performance,loops,cmd,progress
I have a small Python script which sends POST requests to a server and gets their response. It iterates 10000 times, and I managed to print the current progress in command prompt using: code=current_requestnumber print('{0}/{1}'.format(str(code),"10000"),end="\r") at the end of each loop. Because this involves interaction with a webserver, I would...

How to create a Simple Build Script for Visual Studio from the Command Line?

batch-file,visual-studio-2012,cmd,build-script
I have a lot of Visual Studio Project Solutions in multiple directories (all with the extension .sln) and I want to write a simple batch script that will automatically build all solutions listed in the batch file. I am able to manually build a solution by starting up the Visual...

Checking Blank User Input in Batch file (No Input) [duplicate]

windows,batch-file,cmd,scripting
This question already has an answer here: set /p empty answer crash 1 answer So, I am asking the user to make an selection. The point of this question is to catch if the user hit just entered without any input. My plan is to find out if the...

How do I make program with c# to check to see if a word is a palindrome? [closed]

c#,visual-studio,cmd
so i'm trying to make a program (text based) that can scan a word you type into it to see if it's a palindrome or not so just a true or false outcome i'm a beginner with c# so please help me out! So far this is all i have...

Powershell script to run list of sql files

sql,powershell,cmd
I want to read a file that contains a line separated list of *.sql file names (all located at the same directory) to execute the following: $reader = [System.IO.File]::OpenText("_Scripts.txt") try { for(;;) { $line = $reader.ReadLine() if ($line -eq $null) { break } #output $out = $line.split(".")[0] + ".txt" ;...

errorlevel of find /v is always 0

windows,batch-file,cmd,find,errorlevel
When calling a find /V /I only with /V(!) the ERRORLEVEL is always 0 it appears to me. (Using Win7 x64) If, for example, I run the following batch file @echo off SETLOCAL enabledelayedexpansion find /V /I "camstart" testtest.txt echo Errorlevel is !ERRORLEVEL! on this testtest.txt file intrinsicParamStatus(2338763) calibrationFormatID(260) calibrationFormatID(260)...

Check if process indirectly resulted in an error

c#,sql-server,process,cmd
I have the following code that I'm using to open cmd and run the SQL Server setup.exe with a configuration file. ProcessStartInfo pStartInfo = new ProcessStartInfo(); pStartInfo.FileName = "cmd.exe"; pStartInfo.Arguments = "/c /q setup.exe /c /q /configurationFile=../configurationFile.ini"; pStartInfo.WorkingDirectory = installDir + @"\SQL Server Unpacked"; pStartInfo.CreateNoWindow = true; pStartInfo.WindowStyle = ProcessWindowStyle.Hidden;...

How to wait until my batch file is finished

c#,windows,batch-file,cmd,wait
I'm doing a program where I need to start cmd and there start up a batch file. The problem is that I'm using MyProcess.WaithForexit(); and I think it does not wait until the batch file processing is finished. It just waits until the cmd is closed. My code so far:...

Use command-line arguments in VBS [duplicate]

batch-file,vbscript,cmd
This question already has an answer here: Using command line arguments in VBscript 2 answers I'm using the following VBS script to delete the first n number for line from a file: strInputFile = "*Filename.txt" Set objFSO = CreateObject("Scripting.FileSystemObject") Const intForReading = 1 Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)...

Windows command line - filter lines with non-zero values

windows,command-line,cmd
I have a file.data whose content is as below: 140919071513,10,0,1,0,0 140919071513,11,0,1,0,0 140919071513,12,67,1,0,0 140919071513,13,89,1,0,0 140919071513,14,0,1,0,0 140919071513,15,32,1,0,0 140919071513,16,0,1,0,0 140919071513,17,0,1,0,0 140919071513,18,78,1,0,0 140919071513,19,0,1,0,0 140919071513,20,34,1,0,0 I need to run a one-line command in Windows-DOS to get the below output: (non-zero values in 3rd column) 140919071513,12,67,1,0,0 140919071513,13,89,1,0,0 140919071513,15,32,1,0,0 140919071513,18,78,1,0,0...

File association using CMD

file,cmd,associations
What are ways to associate file from cmd? For example,I want .txt file extension to associate with a typical program, through command prompt? what is the correct file association cmd command?

Get the PID of a Windows service by the name of the service

windows,batch-file,service,cmd,pid
Is there a way of getting the PID of a windows service with a command in a batch script by just knowing the name of the service?

Execute net user command from C#

c#,asp.net,cmd,window,window-server
I want to execute net user command from C#. Below is my code:- ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd.exe"); procStartInfo.UseShellExecute = true; procStartInfo.CreateNoWindow = true; procStartInfo.Verb = "runas"; procStartInfo.Arguments = "/env /user:" + "Administrator" + "cmd /K \"net user ABC Admin123# /add\\\""; ///command contains the command to be executed in cmd...

MySQL prompted twice for password

php,mysql,database,cmd,wampserver
So I created a user account for a database entitled "publications" with a password... e.g. GRANT ALL ON publications.* to 'myname'@'localhost' IDENTIFIED BY 'mypasswd'; As usual, I type C:\....address of mysql.exe..." -u username However, it doesn't work and cmd closes! I then type C:\....address of mysql.exe..." -u username -p mypassword...

Is there a way to get Chocolatey to show the progress of a download?

windows,cmd,chocolatey
I just started using Chocolatey and I was wondering is there some flag or setting that I can set to get chocolatey to show me the progress of a download rather than just hanging the terminal. Furthermore, when I do a...... PS C:>cinst something ================================================================================== something is 20% complete You...

How to limit the numbers of processes to start?

c#,cmd
I wrote a program which uses Process.Start to call cmd.exe to call qaac.exe to covert a song to aac. System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = command; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); p.WaitForExit(); It works but...

IF statement in FOR loop not working

batch-file,cmd
I am creating a batch file to initialize a portable game and run it locally on a computer for performance purposes, and another script to save the game to the portable drive when finished and check for updates. Batch File (save, update, & clear local cache) @echo off title Minecraft...

Running .VBS from Batch File

windows,batch-file,cmd
I have been writing some batch files to some specific job in my role as Desktop Support. I have been scripting a Profile Backup script for a couple of months now, changing as the role requires and as new issues crop up. I am trying to run the following VBS...

How to suppress the schtask.exe warning

cmd
When schtask is invoked on the same Task name the schtask.exe prompts to ask if the task is to be replaced as it already exists: schtasks.exe /Create /TN "Disk Space Checker" /TR "powershell.exe D:\DiskSpaceMonitor\DiskSpaceMonitor.ps1" /SC MINUTE /MO 30 How can I suppress this warning and always ask the schtask to...

Powershell code works good on powershell_ise but breaks on powershell

windows,powershell,cmd,wmi,powershell-ise
I'm trying to write a code that "blinks" the lock key leds really fast (using -comObject to sendkeys). The code run really slow on Powershell (from CMD) and miss some keypress, but seems to work great on Powershell_ise. The code reads a file to binary and then transfer each bit...

Batch File: Always Error level - ing

windows,batch-file,cmd
I am Lloyd, and I am new to Stack Overflow. Anyways, I am writing a Batch File about Calculator. But, one thing I noticed, is that the error level always sets to 1 even when there's no error. I also tried this command I've searched in Google: set errorlev=0 But,...

batch result me “echo off” instead the proper result

batch-file,cmd
I have a little problem with the next code @Echo off Title STARTING cls echo. echo Checking running services... echo. timeout /t 2 /nobreak >NUL tasklist /fi "imagename eq cmd.exe" /v | find /I /N "DATABASESERVER" >NUL if "%ERRORLEVEL%"=="1" ( cls echo. echo Database is not running, now will start!...

Keeping the terminal in focus

python,selenium,windows-7,cmd
I have a python script which uses selenium to automate web page, drawing focus away from the terminal where user input is required. Is there anyway in python to switch focus back to the terminal, programmatically? I will be running my program in the Windows Command Prompt on Windows 7,...

How to evaluate a variable with two words in a batch file?

batch-file,cmd,batch-processing
top set /p alt= echo %alt%>>123.txt if %alt% equ *ex* goto ex goto top :ex exit I need to echo something from a batch file to a .txt file. The problem I am facing is when I put two words or numbers or letters with spaces between them the program...

Node spawn cant pipe cmd commands

node.js,cmd,spawn
Hello I'm creating a plugin which uses some command line commands in order to get the process memory and cpu usage how ever altho the command works in terminal it does not when running with node. Furthermore when running with node the findstr part doesnt work at all, and because...