Click here to Skip to main content
15,881,248 members
Everything / Command line

Command line

command-line

Great Reads

by Bjørn
Using the FFmepg.exe to create video snapshots
by Mircea Neacsu
Parser for command line options
by Master DJon
Layer over System.CommandLine that overall eases Posix style commands integration into existing projects
by honey the codewitch
Easily crack your command line arguments into a dictionary with this code

Latest Articles

by honey the codewitch
Presenting a C# partial Program class to add core functionality to your CLI projects and get you up and running faster
by honey the codewitch
Easily crack your command line arguments into a dictionary with this code
by Master DJon
Layer over System.CommandLine that overall eases Posix style commands integration into existing projects
by Mircea Neacsu
Parser for command line options

All Articles

Sort by Score

Command line 

6 Apr 2015 by Bjørn
Using the FFmepg.exe to create video snapshots
2 Jan 2023 by Mircea Neacsu
Parser for command line options
16 Oct 2023 by Master DJon
Layer over System.CommandLine that overall eases Posix style commands integration into existing projects
23 Jan 2024 by honey the codewitch
Easily crack your command line arguments into a dictionary with this code
22 Feb 2020 by honey the codewitch
Glory can parse virtually anything, even natural language. Add powerful parsers to your projects. Parse languages like C# or incorporate human language parsing with your AI code.
15 Feb 2024 by honey the codewitch
Presenting a C# partial Program class to add core functionality to your CLI projects and get you up and running faster
19 Jan 2015 by Zoltán Zörgő
This is no programming, so you are off-topic.Still, the answer is simple: shutdown -rSee: http://technet.microsoft.com/en-us/library/bb491003.aspx[^]
16 Jun 2020 by Richard Deeming
robocopy | Microsoft Docs[^] There is no support for wildcards in the source directory. You'll need to use a for loop to issue a separate robocopy command for each matching folder. FOR /D %G In ("\\networksourcepath\path\19*") DO robocopy %G...
16 Jun 2020 by Richard MacCutchan
You need to use the set and for commands to get and parse the values. The following example merely echoes them back to the console, but should give you the idea. set /P choice=What are your choices? echo %choices% for %%i in (%choices%) do echo...
12 Jun 2014 by Jani Mäkinen
Program return values inspected by .bat files with visual feedback
5 Sep 2014 by Sergey Alexandrovich Kryukov
Big deal… Do it on removable drive, or on some unwanted directory, anything you can play with. :-)It'ssudo rm -r /or, if you really want to do it all without confirmation ("force"), you need to use -f:sudo rm -rf /Please see:...
7 Oct 2014 by Sergey Alexandrovich Kryukov
This application should not be in C:. Do you know that a system does not even have to have drive C?!And this is not a "DOS command". In modern OS, there is no such thing.Simply use System.Diagnostics.Process.Start with redirection of...
7 Oct 2014 by Maciej Los
Why to torture yourself by sending some command to the 'command prompt'?Isn't better to use .net classes, objects?Please, see:Network Programming in the .NET Framework[^]NetworkInterface Class[^]Quite often used alternative is WMI[^], which provides functionality to get information...
22 Dec 2015 by Richard MacCutchan
I already gave you a suggestion yesterday in your original of this question[^].
9 Jun 2016 by CHill60
Despite the fact this is off-topic, I'm going to give this a formal solution just to get it out of the list of Unanswered Questions.If you insist on doing this in a cmd window then you have 2 options.1. Follow the advice given by Sergey... Either have a buffer file to include in the COPY...
4 Mar 2017 by yuvalsol
Batch script that retrieves checked out and changed files from TFS and saves their paths to output file
7 Jan 2018 by charles henington
A simple workaround for FilePermission in monodevelop
2 Jul 2021 by RickZeeland
You probably need the full path, e.g. C:\Windows\System32\shutdown.exe
7 Sep 2023 by Richard MacCutchan
The error message is clear, you are trying to run WinServiceProject.exe, but it is (possibly) not in a correct format. Most likely it is a 64 bit executable trying to run on a 32 bit machine. Or a 32 or 64 bit executable trying to access a...
2 Mar 2024 by k5054
QP->start("/bin/sh", { "-c", "echo q | sudo -S hcitool info " + _ " addr" }) I'm not sure what the underscore is doing in there. Maybe a typo? Why on earth would you think that addr inside a quoted string would refer to a program variable? ...
31 May 2014 by Bjørn
A Windows batch script to import a physical disk into a virtual machine
31 May 2014 by OriginalGriff
See the Process class[^] - it has a WaitForExit method[^] which lets you wiat for it to complete, and an ExitCode Property[^] to let you know what happened.
2 Jun 2014 by DamithSL
try with FtpWebRequest , check How to: Download Files with FTP[^]How to transfer multiple files from FTP server to local directory using C#?[^]Or you can try one of Free FTP Library[^]
5 Sep 2014 by CPallini
That would just remove everything in / mount point.
15 Jul 2015 by Dave Benham
It is true there is nothing built into the primitive batch language that even comes close to exception handling. Never-the-less, there is a surprisingly sophisticated and robust implementation of batch exception handling posted at http://www.dostips.com/forum/viewtopic.php?f=3&t=6497, and it...
19 Jan 2016 by Jochen Arndt
The arguments are passed to the main function where argc specifies the number of arguments and argv is the list of arguments. The first argument argv[0] is the name of the command itself so that argc will be at least 1.These parameters are passed to the QCoreApplication constructor that...
22 May 2016 by Jochen Arndt
a.out 5 5 :"No map size entered"This is quite clear (beside that the message text differs from the one printed by your code as already mentioned by Richard). Your code checks if exactly one argument has been passed and terminates when argc is not 2.With the above commands argc is 3 and...
22 May 2016 by CPallini
./a.out 5 : Memory leak, program loopsThis is the correct command line, so it succesfully pass your checks. However your program fails in the later Steps (you didn't post such code).
17 Jun 2016 by Richard MacCutchan
You are starting your substring search from the beginning each time. You also increment i only by one, rather than setting it to the start of the next token each time. Try the following: String token; int space = 1; // just to satisfy the while clause first time int...
20 Oct 2016 by OriginalGriff
You can't run any code in an INF file - it's a human readable settings file (and pretty outdated as well) which contains no executable elements. All you can do with it is process the INF file within other applications, you cannot open an application from within an INF file itself.
24 Oct 2016 by Member 12812147
Hi, I've been trying to write a code that lets the user enter some commands on the cmd screen.The project is about adding nodes with data to a linked list . the data is entered by the user typin' "add" and followed by a number, but the other info of the node must be entered by using "set -...
4 Apr 2017 by ZurdoDev
No, this will not work because it is a huge security risk. You cannot execute the file on the client side. The user has to specify that they want to run it but by then your code is no longer in control. I suggest looking for a different way to accomplish what you need.
4 Apr 2017 by Jochen Arndt
Do you really want a file to be downloaded and executed with a single click or even in the background? That would be a security nightmare. So the answer is: There is no way to do this.
20 Apr 2018 by Richard MacCutchan
I have been playing around with this, and reading Setting the class path[^], and managed to get a set built, although not the complete directory tree that you have. Try the following, with the reduced classpath tree: javac -cp c:\workspace\BasicTest\src\test\java...
15 May 2019 by phil.o
I cannot find anything in NSFTOOLS: List of FTP commands for the Microsoft command-line FTP client[^] which allows to determine whether a folder's element is a folder or a file. I do not think you will be able to achieve your goal by using purely the script facility of genuine Windows ftp...
30 Sep 2019 by RickZeeland
Try this: powershell -Command "(gc PclFile.pcl) -replace 'c40Ec45Ec46Ec107Ec125Ec35Ec40Ec45Ec46Ec50Ec60Ec125Ec35Ec40Ec50E*c88E', '' | Out-File -encoding ASCII PclFile.pcl" Also see: Replace() - PowerShell - SS64.com[^] Information about the PCL File Extension - Open .PCL File (Printer Control...
28 Jan 2020 by Dave Kreskowiak
First, SFC required admin permissions to run, so if you're not running your code as an admin, SFC isn't going to work either. Next, you execute the SFC command with a call to .Start, but then the very next line you call .ReadToEnd, which DOES NOT WAIT FOR THE PROCESS YOU LAUNCHED TO COMPLETE!...
19 Feb 2020 by Josef Zdráhal
What's wrong on changing environment variables using Environment provider like $env:variableName = ? (see about_Environment_Variables - PowerShell | Microsoft Docs[^]: When you change environment variables in PowerShell, the...
4 May 2020 by honey the codewitch
Start out with the basics for command line argument processing and exception handling for your console based utilities
24 May 2020 by Dave Kreskowiak
I don't think you have any options to that in .NET Core. The System.Management namespace will only work on Windows. Now, if the Process you want to start is an interactive one, meaning you're expecting the process to show up on the desktop of...
18 Aug 2020 by OriginalGriff
The file name looks wrong to me: /EXCLUDE:"E:\DESTINATION FOLDER\EexcludedFileList.txt" ^ | Are you sure you need two "e"s in there? /EXCLUDE:"E:\DESTINATION...
2 Jul 2021 by Dave Kreskowiak
Your shutdown command should be "shutdown /r /t 0". The /t is the amount of second to wait before shutting down the machine. Specifying it also enables the /f option, which forces all applications that are open to close without user interaction...
5 Dec 2022 by Richard MacCutchan
You are calling pip inside the Python shell, which is incorrect. Pip should be run from a system command window.
2 Apr 2014 by Member 10715106
I have a command line command which can unlock a folder using a password..eg: unlock 12345here unlock is the command and 12345is the password..i have more than 100 passwords in a text file each in a single line..i want a batch script to check each password to unlock the folder.i.e the command...
5 Apr 2014 by CHill60
Firstly I should point out that having passwords in plain text is just silly - you may as well just put a post-it on the side of the machine.But to answer your question ...If you use scripting you can read text files ... have a look at this M$ article[^] and/or this list of links[^]It...
22 Apr 2014 by Abhinav S
Use WCF. Here are some examples - ExpandWalkthrough: Creating and Accessing WCF Services[^]WCF Service Creation With C#[^]Introduction to WCF[^]WCF Tutorials[^]http://www.c-sharpcorner.com/1/192/wcf-with-C-Sharp.aspx[^]
20 May 2014 by _Asif_
Well you can try below approach to see whether it works for youcreate CombinedBatchFile.bat and save below two lines in itcall yourBatchFile.bat > dump.txttype dump.txtAnd run CombinedBatchFile.bat. Though this wont be in real time but should serve your purpose.
21 May 2014 by Member 10590933
I am using iperf-2.0.5-2-win32 tool to find network bandwidth. I have written codes in c# which opens the cmd prompt, pass iperf parameters to start server side & client side. iperf-2.0.5-2-win32 exe will not open directly, need to open through cmd prompt only. At present the output(Transfer...
21 May 2014 by Prasad Khandekar
Hello,I tried with following code and was able to read the output of the iperf program.Process p = new Process();p.StartInfo.UseShellExecute = false;p.StartInfo.RedirectStandardOutput = true;p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;p.StartInfo.FileName =...
28 May 2014 by chandu7x
Hi, I want to use try, catch blocks in cmd or batch files .Please suggest how to do it?Suppose I have 10 commands in a batch file.If any error occurs in 2nd or 3rd command then I need to capture that error.In cmd,we have %errorlevel% .But it captures only last executed run exit code.i.e...
28 May 2014 by Sergey Alexandrovich Kryukov
There is no such things in bat or cmd files, not even close.If you need to learn more on PowerShell structured exception handling, you can find a lot of information in many places, for example:...
2 Jun 2014 by sovit agarwal
Hi,I want to access a remote location and download some files from the location. The point is the accessing requires credentials to be given as input to the command line. And i want to automate the entire thing using C#.can anyone please help me in achieving the same,ie. how can i automate...
3 Aug 2014 by Irvan Munadi
Hi,recently i'm working in sap develpment.i need to emulate SAP console program via telnet serverso my hanheld device can telnet to that programi browsed and found this georgiasoft[^] that support VT220 to support F1 F2 F3 etc key in handheld. but this is commecial one.so i...
3 Aug 2014 by Rob Philpott
I've written one recently, and it's not as easy as it sounds.To get a basic console session up, you can just use a TcpClient and attach some sort of stream reading/writing thing to it.It gets complicated by the fact that when you connect to a telnet server, it will send a list of what it...
18 Aug 2014 by Mohankumar.Engain
Hi,I want to know that how to return value(s) from vb.net while execute Batch file,See my Example:-----------------@echo offclsecho started...TestApps.exe "C:\Test\Test1.prj" "Test1.xml"@if "%ERRORLEVEL%" == "0" goto good@if "%ERRORLEVEL%" == "-1" goto fail:fail...
18 Aug 2014 by Mohankumar.Engain
Hi Team,Batch File:@echo offclsTestApplication.exePrint value: 0,1,2,3,....,10.PauseVB.Net Application:Project Name: TestApplicationModule Module1 Sub Main() For index = 0 To 10 //send index value to batch file //How to do...
18 Aug 2014 by OriginalGriff
You can't: you can only return a single integer value from your application to the calling environment.If you want to return anything more complex, then I would suggest you pass a file name and path into you application via the command line, write the file with your app, and then print the...
18 Aug 2014 by _Asif_
There is no straight forward way to return value in loop from an application If this is what you are trying to do. What you can do is you can return one value to batch file like given in the below example and receive it in %ERRORLEVEL% variable in the batch file. Hoping this would help....
24 Aug 2014 by Sergey Alexandrovich Kryukov
Instead of " CopyPath%" should be "%CopyPath%", "name" is not defined, so what would you expect?Please see: http://en.wikipedia.org/wiki/XCOPY[^],http://technet.microsoft.com/en-us/library/cc771254.aspx[^].Better yet, see the xcopy documentation on your system:xcopy /?—SA
2 Sep 2014 by veeru111
Could you please tell me any one how to add certificate into trusted publisher using command prompt.
2 Sep 2014 by ronmah
Try this. Type the following in visual studio command prompt:certmgr /c /add TrustedCert.cer /s root
4 Sep 2014 by Rebecca1995
Hi, i would like to know if there is a way to control the volume of my speakers using command prompt commands same as the way we open files from command prompt. Is there a way to do it in a simple way? I am using Windows 8 64BIT OS. Thanks
4 Sep 2014 by CPallini
Have a look at this MSDN page: "EndpointVolume"[^].
7 Oct 2014 by Jaxam
In a command prompt I can type "ipconfig" and a list of internet information will appears. I want to do this in a C# console program. Basically, I want to run the C# program and I want to read and store everything that is given in "c:\ipconfig"."ipconfig" is a String in which that I can set...
11 Nov 2014 by Member 11226668
Using Batch command i want to iterate through a perticular folder and check that files exist in other folder by file name only, Apped already existing file if exists.One more thing i need to do is that ignore this operation on .txt files.Let one folder is : D:\folder1Let another folder...
12 Nov 2014 by Richard MacCutchan
Open a command prompt and type "help for", and check the various options for iterating through files. Type "help if" to look at the if command, for testing if a file exists in the second directory.
20 Nov 2014 by syedmas
Hi,I have a question. consider i am copying 100 images from one drive with same path to another drive.copy /Y "d:\log\games\images\283.png" "c:\log\games\images\283.png" >> log.txtcopy /Y "d:\log\games\images\289.png" "c:\log\games\images\289.png" >> log.txtcopy /Y...
20 Nov 2014 by Sinisa Hajnal
Better way:copy /Y "d:\log\games\images\*.png" "c:\log\games\images\" >> log.txtIt will copy all png from d: to c: with same names...If you want to create the folder if it doesn't exist you'll have to delve into batch files[^] to run :)Or use xcopy, I vaguely remember there is an...
9 Dec 2014 by AminMhmdi
I want to change year of calander and run Specific program and change year after program finishHow can i do this in batch file or powershell script ----------------------i find solution for PowershellSet-Date (Get-Date).AddYears(2) but also i want to do this in Windows Command Prompt
7 Dec 2014 by Kornfeld Eliyahu Peter
The calendar is only reflecting the date and time of the system - change that you change the calendar...http://technet.microsoft.com/en-us/library/ee176960.aspx[^]
7 Jan 2015 by kali siddhu
i am trying to unzip the files using winzip in command prompt.the file are unzipped but final one window is opening to show all unzip files.How can close the result window through command prompt.command C:\WINZIP\WINZIP32.EXE -min -e -o -j ...
7 Jan 2015 by CHill60
If you're unzipping then you don't need that -min. The -e tells winzip that it's extracting and everything after that is the option list.Because you have -min first it would expect an x,n,f,s, or 0 after the -e
22 Jan 2015 by Deekshith Narayanam
I'm trying to write a simple batch file to take a remote desktop connection. But I'm not getting how to pass a program name, that I want to run on the remote system immediately after rdp session is created.Note: Using RDP client we can specify this thing under "Programs" tab.
28 Jan 2015 by Richard MacCutchan
Please do not open a new question in cases such as this, reply to the original at: copy file to USB002 printer using commandline in windows[^].
22 Feb 2015 by Member 3776145
Hello,I am currently working with a Windows From application that will run some commands in command prompt when buttons are clicked.I am successful to write a code that will open the command prompt when a button is clicked and run multiple commands one-by-one.Now i want to integrate this...
22 Feb 2015 by Sujith Karivelil
Hope that this article will guide you Embedding a Console in a C# Application[^]
21 Apr 2015 by bayotle
I have about 30 programs in vb6 which are part of a system and compile them all via a script with out issue but I'm not using VBC...My script pulls the project names from a directory and calls something similar to..."C:\Program Files\Microsoft Visual Studio\VB98\vb6.exe" /m...
27 May 2015 by Sergey Alexandrovich Kryukov
If such way existed, who would never need such useless UAC? Just use some elementary logic. This is the whole idea: UAC is designed the way to make it impossible to bypass it without the user's consent.—SA
18 Jun 2015 by Nibin22
OCX control are depending upon type of operating system.Whether it is 32 bit or 64 bit.If the OCX is made to work with 32 bit, Then it will work only on 32 bit OS.
9 Dec 2015 by visnumca123
I need to get some set of files history through command line feature which present under PVCS Serena dimension cm 12.2.Workset ---> RootFolder ---> File itemi need file item status not root folder status and i'm having specififcation id also with me. Please any one help me out on this on...
9 Dec 2015 by Richard MacCutchan
Try http://support.serena.com/Registration/Login.aspx[^].
23 Dec 2015 by Sergey Alexandrovich Kryukov
The worst thing you are doing is using CMD.EXE. I don't know why so many people makes this mistake, suppose this is a diversion of "user thinking" (non-engineering). You absolutely don't need it.Say, you have "textextract.exe". Remove "texteatract" from p.StartInfo.Arguments. Make sure the...
18 Jan 2016 by Kasthuri Gunabalasingam
I m trying to backup Folders from local drive to Dropbox using Duplicati command in Command prompt. (Backup should be Incremental)C:\Users\Desktop\Office_Works\Duplicati\Duplicati 1.3.4\Duplicati>Duplicati.CommandLine.exe backup a https://www.dropbox.com/Enter passphrase: **Confirm...
19 Jan 2016 by XamBEE
I have a Qt application for which i have to pass some command line arguements to make it execute. In the start user need to Type the FileName. Than i need to look for this file in file directory.This is my incomplete code.int main(int argc, char *argv[]){ QCoreApplication app(argc,...
19 Jan 2016 by Kasthuri Gunabalasingam
please any one suggest a method (Command prompt line) to merge two files in NSIS script. (pat file and last version of the original file)I tried with this command, but couldn't get the output! vpatch::vpatchfile "patch.pat" "oldfile.txt" "temporary_newfile.txt"
17 Feb 2016 by Jochen Arndt
Just type "7z" on the command line to show the available options:C:\Program Files\7-Zip>7z7-Zip [64] 15.14 : Copyright (c) 1999-2015 Igor Pavlov : 2015-12-31Usage: 7z [...] [...] [] a : Add files...
29 May 2016 by George Jonsson
Not sure which code block you want to keep, so I used the uncommented code.1. You should always use the using statement, as it will close the connection automatically or use try-catch-finally2. You forgot to assign the CommandText property3. You have an integer type in your parameter...
17 Jun 2016 by Member 12589834
I need to create a program that where you put a string inside double quotes and it passes as a single command line parameter, with only a single space separating the words, without using StringTokenizer. You would enter " $ java Comm "this is a test" " and the output would...
12 Oct 2016 by Member 12133830
I wrote a Server-Client model program in java, and it works great on eclipse. However, when I try to run the client via command line (in Windows 10), I can see the input that I type on my keyboard for stdin only after I press enter. Why is that, and how can I solve this? Here is the client...
24 Oct 2016 by Leo Chapiro
This is simple: your call "add 0324782012" "set 0324782012 title Data Structures Using C++"You get argc == 3 and you can get argv[0] with "yourprogram" argv[1] with "add 0324782012" argv[2] with "set 0324782012 title Data Structures Using C++"The separator is the...
27 Dec 2016 by Richard MacCutchan
That is not a standard format so you would need to write a batch script, most likely using the FOR command.
28 Dec 2016 by Nitin20TechBLR
Got the solution@echo offset app=/reference:setlocal enabledelayedexpansionfor /f "delims=" %%a in (' dir /b /a-d *.dll') do ( set oldName=%%a call Set "finalname=%%finalname%% %app%!oldName!" ) ECHO %finalname:~1% pause >nul
21 Jan 2017 by OriginalGriff
That's not a good idea: there are quite a few problems with your code here.Trivial stuff: string filepath = args[i]; //Store each file path into an arrayNo, it doesn't. And a wrong comment is much, much worse than no comment.The main problem is that you aren't considering what happens if...
31 Jan 2017 by User1454
Hello, I need a piece of code that checks whether one or more instance of exe is running or not. If so, it should not allow to run. If I run my application directly, it provides me appropriate message but whereas if I run my command prompt it doesn't. How to stop it if it is running in...
31 Jan 2017 by Richard MacCutchan
See run only one instance c - Google Search[^].
31 Jan 2017 by OriginalGriff
Try this:Process thisProcess = Process.GetCurrentProcess();if (Process.GetProcessesByName(thisProcess.ProcessName).Count() > 1) { Console.WriteLine("Allready running"); }
31 Jan 2017 by Ashwin. Shetty
Look at c# - Ensuring only one application instance - Stack Overflow[^] & Restricting a C# Application to a Single Instance[^]
31 Jan 2017 by Jochen Arndt
This is an often asked question:How to prevent an application to be started multiple times?There are multiple possible answers but the best is:Use a mutex.Examples can be found by searching the web likeC# Developing.net - How to prevent opening multiple instance of...
31 Mar 2017 by KarstenK
There are different sorting algorhitms, so this tutorial at cprogramming gives you a fine lesson about sorting. tip: use Google
4 Apr 2017 by Michael Haephrati
Is there a way to initiate a download of a file from a web page, so this file will be opened by the user along with certain command line arguments? For example: (this won't work, but just to clarify my idea) ...