Click here to Skip to main content
15,891,607 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 Title

Command line 

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
7 Jan 2018 by charles henington
A simple workaround for FilePermission in monodevelop
3 Aug 2020 by Member 14864964
In the following batch script, I would like to be able to input multiple choice at a time from the menu. For example, choice 1, 3 and 5. And make the /LOADFILES argument take only one item at a time using a loop : @echo off setlocal set...
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...
3 Aug 2020 by l o o l
Something very similar I did some time ago, below is an adaptation / merging with your code and also using for... this is string %errorlevel% == 1 and this is int comparation %errorlevel% EQU 1 @echo off && setlocal enabledelayedexpansion...
6 Apr 2015 by Bjørn
Using the FFmepg.exe to create video snapshots
12 Nov 2022 by PartisanIsaac
I was making a small block drawing package with Node.js, and i was tinkering with it, but at the exact moment i put a ANSI Color code, it started to break. Before: Image[^] After Image[^] The reason that makes it break is that all the...
11 Nov 2022 by OriginalGriff
That's because ANSI escape sequences are just that: sequences. They have a common format: They start with an ESC character, and the following character either completes the sequence are indicates a Control Sequence if is is an open square...
12 Nov 2022 by Dave Kreskowiak
Quote: The reason that makes it break is that all the characters i use to make the ANSI codes work are being treated as just normal characters when i use the string .length property. That's because, in the terms of a string, they ARE normal...
4 Dec 2014 by Member 8073143
Hi all tech geeksi am using the following command all is fine it deleted the files from the folder i just want to add another condition that the files which are 3 days older gets only deletedpushd "C:\Bhaskar_Backup\Mail_BOX" && (rmdir . /s /q & popd )
4 Dec 2014 by Tomas Takac
I found this on StackOverflow: DOS Batch file to find “new” files by date[^]Then you just need to go trough the list in a FOR loop and delete the files.
4 Mar 2017 by yuvalsol
Batch script that retrieves checked out and changed files from TFS and saves their paths to output file
8 Jan 2018 by Ehsan Sajjad
This is a step by step guide for beginner on how to install .NET Core 2.0 and create a Console Application without any IDE using Command Prompt/PowerShell
15 Oct 2018 by Patrick Skelton
I have what I thought would be a dead easy question to find an answer to. Having really, really tried to get on with PowerShell, I find its syntax to be arcane to say the least. I don't doubt its power but I'm not a sysadmin and I don't do batch scripting very often. So every time I come back...
15 Oct 2018 by #realJSOP
This CP article might help: Compiling C# Code at Runtime[^] You could essentially create a CSharpScript app that loads a text file that contains C# "script" code and compile that script at runtime. You could also write pre-compiled plugins for your script runner app, and specify the DLL...
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...
7 Oct 2014 by User 11060979
You can use the class Process and Redirect Input and Output of cmd.exe.More or less an easy Thing, simply read the doc in MSDN an Play a Little bit.BTW 1.) it is not DOS it is as you mentioned also "command prompt". BTW 2.) There are other/better ways to get the same...
7 Oct 2014 by PIEBALDconsult
My ProcessCommunicator[^] article may give you an idea of how to do that and some of the pitfalls.I'd also like to point out that maybe the console app that processes the output needn't actually execute the command. You can write a processor app that reads its input from a...
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 Aug 2018 by Dinesh Kumar Dora
Hello friends, I am wondering if we can pass different count of commandline arguments to a console application. for example: test.exe test.exe arg1 test.exe arg1 arg2 test.exe arg1 arg2 arg3 all the above 4 cmdprompt invocations must work. Is it possible? i tried the params option as shown...
22 Aug 2018 by Richard MacCutchan
string argHTTPS = args[0]; string argCustDBName = args[1]; That will only ever work if you have two or more parameters. If you want it to be dynamic then you need check how many parameters are being passed in. Start by setting default values for all the optional parameters,...
22 Aug 2018 by Dave Kreskowiak
Your code doesn't make any sense. If the user doesn't pass in any args, it starts a Windows Forms app. If the user does pass in arguments, you add every argument to what appears to be a List (I have no idea because you never show the definition of mainObject!), assign the first two arguments to...
10 Nov 2020 by Yisrael Lax
.NET Library for automatically validating and casting console input parameters
2 Jan 2023 by Mircea Neacsu
Parser for command line options
6 Sep 2022 by Member 14686752
Powershell Command is: Set-NetIPInterface -InterfaceIndex 11 -InterfaceMetric 99 This command is working when I run it on PowerShell as admin. but: C# Code PowerShell ps = PowerShell.Create(); ps.AddCommand("Set-NetIPInterface -InterfaceIndex...
31 Aug 2020 by Garth J Lancaster
Try setting it up like this Executing PowerShell scripts from C# | Microsoft Docs[^] I do like the using (PowerShell PowerShellInstance = PowerShell.Create()) { // ... } (using) to set up and tidy up the Powershell instance
31 Aug 2020 by OriginalGriff
Check that your C# app has been elevated: if it isn't running as an admin, then nothing it tries to run will be either.
6 Sep 2022 by Member 15758983
Use AddScript() instead of AddCommand() and it will work
5 Sep 2014 by Nick Salesky
I had an idea for something in the terminal/command line that would basically delete EVERYTHING very very VERY easily. I didn't want to try it on my computer, but theoretically do you think it might work? sudo rm -r /
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:...
5 Sep 2014 by CPallini
That would just remove everything in / mount point.
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...
22 Sep 2014 by Sanman Marathe
Hi Guys,I have .csproj file which creates the build artifacts when i Check in something or do a Force Build.The tool we're using is AntHill Pro to build and create artifacts.Now, mine is a Dotnet application, the current build happens successfully and creates normal dll's and evrything...
29 Jul 2021 by OriginalGriff
Repost: Deleted. Please do not repost your question; use the Improve question widget to add information or reformat it, but posting it repeatedly just duplicates work, wastes time, and annoys people. I'll delete this one.
7 Apr 2015 by vipulnegi
Hi Folks,I have VB porject, which is compiling/buidling perfectly using vb6 IDE in XP mode.My objective is to automate the deployment process, so am trying to build this project in command line using VBC.But while compiling vb project in window 7 using VBC.exe and cmd its throwing...
7 Apr 2015 by den2k88
We can't see your code, nor access your HD in any way. Please give us more informations to work with.I may try to guess: as far as I know VBC exist for .NET projects - I don't have any similar utility in my VB6 Enterprise installation. Not only that but "namespace level" is a concept non...
7 Apr 2015 by Afzaal Ahmad Zeeshan
All of these are compiler thrown exceptions (errors). Some say, identifier was expected (example context is when you miss the identifier while creating an object), some say Class doesn't end with exact matching End Class; check for any typo. Again that Module thing... Do you know the VB language...
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...
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[^].
13 Aug 2016 by Zdenek Jagrik
A template for Windows Form Application written and compiled without Visual Studio.
6 Mar 2016 by FrostedSyntax
How to create batch files that make navigating the filesystem in the command prompt a breeze.
27 Aug 2021 by Member 9720862
I use ffmpeg.exe and use Command Line for set logo on vedio. I have execute this command : C:\Users\admin>ffmpeg.exe -i testv1.mp4 -i 2.jpg -filter_complex "overlay=X:Y" output.mp4 What mistake I do in Command ? please help me What I have...
27 Aug 2021 by OriginalGriff
This has nothing to do with software development, which is what this site is all about. |Try the official site: Contact Us[^] - it has links to various support forums.
24 May 2020 by Member 12885549
want to execute cmd command with arguments in my .NET Core application. The problem is that I have to call it in external computer. I now IP, user, password of VM, the command that's needed to execute and its arguments. However I have trouble...
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...
22 Dec 2015 by Richard MacCutchan
I already gave you a suggestion yesterday in your original of this question[^].
4 Apr 2018 by Eric Lynch
A flexible command line parsing class that uses C# attributes and reflection to discover syntax
15 Feb 2021 by Member 14864964
Hello, using a batch file, on my admin account, I would like to load the regedit hive of a disconnected windows user (NTUSER.DAT). Then, getting part of the "RemotePath" value of one of his mapped drive (what comes next \\\\server\\users\\) : ...
15 Feb 2021 by Richard Deeming
According to this StackOverflow answer[^], it is possible to do this in Powershell. reg.exe load 'HKLM\TempHive' Path\to\offline\file.dat $path = Get-ItemProperty -Path "HKLM:\TempHive\Network\z" -name RemotePath | Select-Object -ExpandProperty...
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.
18 Nov 2022 by Jackie Lloyd
I am writing code in C#. My code has a command to run an exe from a shell command: $"/C {hospitalPath} /R {bdbPath} /M {bmiPath}"; It is a very obscure app called 'hospital'. The bdbPath and bmiPath are paths to files. If any of the files are...
17 Nov 2022 by RickZeeland
Maybe you can use something like this: Process.Exited Event (System.Diagnostics) | Microsoft Learn[^]
18 Nov 2022 by PIEBALDconsult
I've used something like the following to automate the clicking of OK on some named window. Spin up a thread which polls for the existence of the pop-up and click it if it does. [ ...
17 Feb 2016 by azimkhandouzi
hello..i created a 7z archive yesterday.i want to add a few files to that, today , how can i do this by 7z archive command line.thank you...What I have tried:how can add file to 7z archive later
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...
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"[^].
2 Apr 2018 by Babiiii
Good evening, I've been trying to create my own C# program that can message another Computer within the network. Unfortunately, none works. Please help me to make a C# Program that can pop-up message or notification message another computer within its network. What I have tried: I tried ...
2 Apr 2018 by RickZeeland
I think it would be easier to use SignalR, see introduction here: SignalR | The ASP.NET Site[^] See examples here: c# - SignalR Console app example - Stack Overflow[^] Tutorial: SignalR Self-Host | Microsoft Docs[^] SignalR Chat App With ASP.NET WebForm And BootStrap - Part One[^]
18 Aug 2020 by Siddharth Rai
hi, i am using Exclude command with XCopy /Y "E:\SOURCE FOLDER\" "E:\DESTINATION FOLDER\" /EXCLUDE:"E:\DESTINATION FOLDER\ExcludedFileList.txt" it is showing error can't read file. I think this is because of EXCLUDE command.EXCLUDE command...
18 Aug 2020 by Richard MacCutchan
That is correct. The command processor treats a space as a parameter separator, so you must put such a path name in quotes to ensure it is treated as a single item. Are you sure you have spelled the filename correctly?
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...
31 May 2014 by sovit agarwal
Hi, i need to run a command from Command prompt using C# with few arguments and it should run in the background. Once it is completed running, it should return some status or in case of any error it should report the same.The command line argument is as follows:C:\program...
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.
1 Jun 2014 by sovit agarwal
var proc1 = new ProcessStartInfo(); string anyCommand="your command"; proc1.UseShellExecute = true; //proc1.WorkingDirectory = @"set your directory"; proc1.FileName = @"C:\Windows\System32\cmd.exe"; //proc1.Verb = "runas"; ...
13 Oct 2015 by Sunil Bharati
i need to automate my deployment process and i have used clearcase tool for code checkins and all other stuff. I need to rebase the code and take the latest code and build it and create .MSI and then install it. So i just got stuck into the Rebase thing. i need to rebase the code through batch...
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...
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[^]
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[^]
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...
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...
27 May 2015 by Member 11579826
Hi,I'm trying to find a way to disable UAC for a specific application using the command line. All I've found is a way to disable UAC completely for the admin but I need to only disable it for a application. I'll be applying this to a batch script. Any suggestions would be appreciated.
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
19 Feb 2020 by Member 14156312
I want to set an environment variable automatically, without executing the cmd first, then echo the environment to show the value of the environment variable. I tried this code, I store the value as cmd file that I want to set as an environment variable. If I want to show the environment value,...
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...
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 -...
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...
9 Jun 2016 by Member 12573208
I have two csv files in different folders and would like to merge them. I am using copy command in windows cmd but the first line from second file is getting appended to the last line of first file.How do I start copying from new line. COPY t1.csv + t2.csv result.csvresult.csv file is...
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...
2 Mar 2024 by Salvatore Terress
I need to have option "addr" as variable. As used now is a symbol...is it not ? What is the proper syntax? ..as defined / used here char addr[19] = { 0 }; ba2str(&(ii+i)->bdaddr, addr); QP->start("/bin/sh", {...
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? ...
4 Mar 2018 by Member 13707321
My school assignment is a bank account program that can run in two modes, interactive and bash mode. Right now I'm working on bash mode and need to accept command line arguments to open a database account (just a text file with info for different accounts, like names, account numbers, passwords,...
3 Mar 2018 by OriginalGriff
The way I'd do it is to parse the commands twice: first parse separates out the "files" from the "switches", and verifies the basics: one and only one file plus a number of switches. Then it's simple: open your file, and process the swiches.
4 Mar 2018 by CPallini
I would use what GNU provides (Parsing Program Arguments (The GNU C Library)[^]). Since yours is an assignment it could not be a viable alternative.
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[^]
23 May 2016 by Member 12539276
I'm trying to create a 2D grid for the following command line argument, but I can't seem to figure out how to run it within a Putty terminal:if (argc!=2){ cerr
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).
6 Dec 2022 by Aalam Pratap Bedi
(env0) C:\Users\AS\OneDrive\Documents\Python Project 01>python run.py Traceback (most recent call last): File "C:\Users\AS\OneDrive\Documents\Python Project 01\run.py", line 1, in from flaskblog import app ImportError: cannot...
6 Dec 2022 by OriginalGriff
Read the error message: ImportError: cannot import name 'app' from 'flaskblog' Try from site.views import app Instead.
6 Dec 2022 by Richard MacCutchan
I suggest you go to Quickstart — Flask Documentation (2.2.x)[^] and work through the tutorial.
23 Jul 2017 by Member 13323952
How do i use command prompt tool given in the bellow link to download images from twitter https://github.com/Mincka/DMArchiver/blob/master/README.md? What I have tried: How do i use command prompt tool given in the bellow link to download images from twitter...
23 Jul 2017 by Kornfeld Eliyahu Peter
It is unclear why and how you picked this specific tool for the job, but as you did so I would except you to read the documentation... It has clear samples for installation and usage... GitHub - Mincka/DMArchiver: A tool to archive the direct messages, images and videos from your private...
22 Jan 2017 by Javiertxl
My C# classes will create a GUI that takes in csv files and plot a line graph accordingly (Refer to: C# Read string from CSV file and plot line graph for graph code[^]). Currently, my graphs are plotted and saved using the GUI file dialog.What I am trying to do now is to read, plot and save...
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...
21 Jan 2017 by Richard MacCutchan
See Environment.GetCommandLineArgs Method (System)[^].