- How to Execute ShortCut From Command line in Windows 7
- 5 Answers 5
- Execute CMD commands using C++
- 3 Answers 3
- Not the answer you’re looking for? Browse other questions tagged c++ windows cmd command or ask your own question.
- Linked
- Related
- Hot Network Questions
- Subscribe to RSS
- execute from command line sys argv
- 1. Включаем DEBUG
- 2. Отключаем кэширование
- 3. Включение просмотра статики
- 4. Файл запуска dev
- 5. Запуск django
- How To: Execute command line in C#, get STD OUT results
- 18 Answers 18
- How do I run two commands in one line in Windows CMD?
- 21 Answers 21
How to Execute ShortCut From Command line in Windows 7
We came with a scenario where we have to use Shortcut file ( .lnk ), which is on the desktop, to execute an application for a headless device (i.e, without manual intervention).
Is there any way to execute it from Command prompt?
5 Answers 5
If you use double quotes around your «long file names.lnk» and you have appropriate privileges, it will execute. Quotes are needed when spaces exist in LFN’s.
E.g. «C:\Users\Sunny\Start Menu\Programs\XBMC\xbmc.lnk» opens up XBMC. The same is true for the Run box Win + R «path and filename.lnk» , Enter
START filename.lnk should do the trick
As long as there is no exe with the same name as the shortcut, you can omit the .lnk, so just START filename
The above solutions didn’t work for me in 2017, so I experimented a bit.
It turns out that Windows (10 atleast) does make a distinction between shortcuts that link to a local path and shortcuts that are an url. What I found was that
- local paths use the suffix .lnk
- url-like paths have the suffix .url
So a shortcut to https://superuser.com/ would have the suffix .url while a shortcut to C:\Windows or to special locations like Control Panel would have the suffix .lnk .
If you want to execute the shortcut simply type shortcut.suffix in the cmd prompt where .suffix is the suffix according to the rule above. You must first cd to the folder containing your shortcut or enter the full path to the file. In your case
entered into either the run dialog box (invoked via Win + R ) or the cmd prompt would do the trick.
Execute CMD commands using C++
In my project I want to execute some CMD commands. What is the syntax for doing that using C++.
3 Answers 3
You can execute Windows Command prompt commands using a C++ function called system(); . For safer standards you are recommended to use Windows specific API’S like ShellExecute or ShellExecuteEx. Here is how to run CMD command using system() function.
You should place the CMD command like shown below in the program source code:
Here is a program which executes the DATE command in CMD to find the date:
Use Windows specific APIs:
I suppose you could always do:
This however, automatically sets the path to the folder your file is in. Just type cd\ to return to base file.
Not the answer you’re looking for? Browse other questions tagged c++ windows cmd command or ask your own question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
execute from command line sys argv
13 июня 2017 в 19:00
Существует множество вариантов разделения настроек Django под режим разработки. Сейчас вынесу свой вариант. Быть может он встречается где-то еще, я не смотрел. Основным критерием для меня являлось отсутствие лишних наследований на production режиме, возлагая эти нюансы на dev.
Для начала создадим файл devsettings.py рядом с settings.py и запишем в нем одну строчку:
Таким образом наш новый файл полностью копирует содержимое settings.py. Теперь мы можем определить настройки settings.py под production, а в devsettings.py переопределить их для developer режима.
1. Включаем DEBUG
Основная особенность developer режима — включенный debug. Для этого добавляем в наш файл строчку:
При установленном DEBUG = False в файле settings.py, мы получаем наше основное ответвление между режимами.
2. Отключаем кэширование
Чаще всего в production режиме включено кэширование, Однако, в developer режиме с ним работать невозможно. Для того, чтобы в developer режиме кэширование было отключено, нам надо удалить с переменной MIDDLEWARES нужные компоненты и удалить переменную CACHES.
Теперь, при запуске в developer режиме кэширование будет отключено.
3. Включение просмотра статики
На production серверах, как правило, django не занимается отдачей статики. Однако, в developer режиме нам не особо нужны дополнительные средства, аля Nginx или Apache, ведь Django в дебаг режиме может отдавать файлы сам. Однако, эта конфигурация на production сервере не нужна. Для этого нам надо переопределить стандартный файл urls.py. Создадим отдельный файл devurls.py рядом с urls.py со следующим содержимым:
То есть, файл devurls.py будет полностью копировать urls.py, но будет расширять его, добавляя в него дополнительные роутинги для отдачи статики. Теперь изменим наш devsettings.py, чтобы он принимал этот файл роутинга:
4. Файл запуска dev
Теперь мы имеем два набора конфигураций для dev и production режимов. Причем, для production режима ничего не поменялось, и он работает напрямую, но dev режим наследует production настройки и расширяет их. Таким образом мы можем дополнять конфигурацию нашего сервера как угодно, и она будет изменяться на обоих режимах.
Осталось только создать среду для запуска dev режима. Для этого создадим файл devmanage.py рядом с manage.py. Скопируем в него содержимое файла manage.py, изменим только инициализацию конфигурации DJANGO_SETTINGS_MODULE с project.settings на project.devsettings.
5. Запуск django
Теперь у нас есть две отдельные среды под dev и production режимы. Мы можем запуститься в режиме разработки
I am new to Python and Django. I am trying to install Django on Linux. Python version currently available on the server is Python 2.4.3 I installed Python 3.4.2 following the below steps:
The python correctly got installed. so when I do /root/python3/bin/python3.4 I get Python version 3.4.2 so i created a soft link -> ln -s /root/python3/bin/python3.4 python3
Now i created a virtualenv through
then i installed DJango:
Django got successfully installed
Created the project myproj:
myproj project successfully created:
now when i do python manage.py migrate i get error:
When i execute command python manage.py runserver i get error:
I tried all the solutions provided in all stackoverflow discussions.
Django version -> 1.9
I have not added any environment variable like PYTHONPATH or PATH. DO i need to do it. If yes please let me know what to set and how to set.
Requesting you all to please help in resolving this error so that i can start working on Django. Its almost more than 3-4 days i am struggling.
Я новичок в Python и Django. Я пытаюсь установить Django на Linux. версия Python в настоящее время на сервере Python 2.4.3 Я установил Python 3.4.2, следуя шагам, описанным ниже:
Питон правильно был установлен. поэтому , когда я /root/python3/bin/python3.4 могу получить Python версии 3.4.2 , так что я создал мягкую ссылку -> ln -s /root/python3/bin/python3.4 python3
Теперь я создал virtualenv через
Затем я установил Джанго:
Джанго был успешно установлен
Создан MYPROJ проекта:
MYPROJ проект успешно создан:
Теперь , когда я делаю python manage.py migrate я получаю ошибку:
Когда я выполнить команду python manage.py runserver я получаю сообщение об ошибке:
Я перепробовал все решения, предусмотренные во всех дискуссиях StackOverflow.
версия Джанго -> 1,9
Я не добавил переменные окружения как PYTHONPATH или PATH. Нужно ли мне делать это. Если да, дайте, пожалуйста, мне знать, что установить и как установить.
Запрос всех вас, пожалуйста, помощь в решении этой ошибки, так что я могу начать работать на Django. Его чуть ли не больше, чем 3-4 дня я борюсь.
How To: Execute command line in C#, get STD OUT results
How do I execute a command-line program from C# and get back the STD OUT results? Specifically, I want to execute DIFF on two files that are programmatically selected and write the results to a text box.
18 Answers 18
Here’s a quick sample:
There one other parameter I found useful, which I use to eliminate the process window
this helps to hide the black console window from user completely, if that is what you desire.
The accepted answer on this page has a weakness that is troublesome in rare situations. There are two file handles which programs write to by convention, stdout, and stderr. If you just read a single file handle such as the answer from Ray, and the program you are starting writes enough output to stderr, it will fill up the output stderr buffer and block. Then your two processes are deadlocked. The buffer size may be 4K. This is extremely rare on short-lived programs, but if you have a long running program which repeatedly outputs to stderr, it will happen eventually. This is tricky to debug and track down.
There are a couple good ways to deal with this.
One way is to execute cmd.exe instead of your program and use the /c argument to cmd.exe to invoke your program along with the «2>&1» argument to cmd.exe to tell it to merge stdout and stderr.
Another way is to use a programming model which reads both handles at the same time.
How do I run two commands in one line in Windows CMD?
I want to run two commands in a Windows CMD console.
In Linux I would do it like this
How is it done on Windows?
21 Answers 21
Like this on all Microsoft OSes since 2000, and still good today:
If you want the second command to execute only if the first exited successfully:
The single ampersand (&) syntax to execute multiple commands on one line goes back to Windows XP, Windows 2000, and some earlier NT versions. (4.0 at least, according to one commenter here.)
There are quite a few other points about this that you’ll find scrolling down this page.
Historical data follows, for those who may find it educational.
Prior to that, the && syntax was only a feature of the shell replacement 4DOS before that feature was added to the Microsoft command interpreter.
In Windows 95, 98 and ME, you’d use the pipe character instead:
In MS-DOS 5.0 and later, through some earlier Windows and NT versions of the command interpreter, the (undocumented) command separator was character 20 (Ctrl+T) which I’ll represent with ^T here.
A quote from the documentation:
Using multiple commands and conditional processing symbols
You can run multiple commands from a single command line or script using conditional processing symbols. When you run multiple commands with conditional processing symbols, the commands to the right of the conditional processing symbol act based upon the results of the command to the left of the conditional processing symbol.
For example, you might want to run a command only if the previous command fails. Or, you might want to run a command only if the previous command is successful.
You can use the special characters listed in the following table to pass multiple commands.
& [. ]
command1 & command2
Use to separate multiple commands on one command line. Cmd.exe runs the first command, and then the second command.
&& [. ]
command1 && command2
Use to run the command following && only if the command preceding the symbol is successful. Cmd.exe runs the first command, and then runs the second command only if the first command completed successfully.
|| [. ]
command1 || command2
Use to run the command following || only if the command preceding || fails. Cmd.exe runs the first command, and then runs the second command only if the first command did not complete successfully (receives an error code greater than zero).
( ) [. ]
(command1 & command2)
Use to group or nest multiple commands.
; or ,
command1 parameter1;parameter2
Use to separate command parameters.