How to run VSCode from the command prompt - windows

I for security reasons cannot run VSCode plainly. I have opened it in the past, but now due to specific reasons, I may only run VSCode from the command prompt. I've tried
start "path/to/file" code and start code "path/to/file"
but none work I'm on Microsoft Windows [Version 10.0.17134.407]
how may I run this by going to Windows+R then 'cmd' then start/ run?
Also it would be great if I could use this for a separate user.
I'm looking for something like:
Runas /user:user\admin /savecred "C:\Program Files (x86)\vs-code.exe"

The use of start is useless if VSCode is in the environment variables.
You can use code C:\Users\%username%\Desktop\File.c for exemple.If it doesn't work, I advise you to use a vbs script instead
You also don't need to run VSCode as an administrator unless you need to edit a file in a protected folder.

Maybe not the exact answer to the question, but...
To start Visual-Studio-Code from CMD into the current folder write:
code %cd%
The environment variable cd tell VS-Code to open it with the current folder

just open a cmd terminal and type code followed by

just open a cmd terminal and type code followed by return keyborad key.

Well shoot, as it turns out that after doing some experimentation I found out that there's a way. Do this:
Simply stick this:
runas /user:Techtiger255\admin /savecred "C:\Users\Admin\AppData\Local\Programs\Microsoft VS Code\Code.exe"
inside of a shortcut (.lnk file)
Open your command line of choice (Powershell or Cmd) and enter the exact file path of your shortcut ex:
"C:\Users\Standard\Desktop/VSCODE.lnk" and hit go, stupidly simple really, just had to find the code.exe file path.

Related

How to set ps as shortcut to open powershell

The question says it all. I want to learn and use powershell as my go to terminal in windows and I want powershell to open if I type Win+R followed by ps. Much like how cmd is used to open command prompt.
You can create a symbolic link (similar to a shortcut) to Powershell with any name you want.
This will create one called ps.exe in the powershell folder, this folder is already listed in PATH so will enable you to run ps from the RUN box like you want.
mklink %SystemRoot%\system32\WindowsPowerShell\v1.0\ps.exe %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
Be sure to run the command in an elevated command prompt.
The "default" command for opening PowerShell is powershell. If you want to make it ps, your best bet is to create a batch file named ps.bat containing the single line
#powershell %*
and place it in one of the directories named in your system PATH variable.

How to launch a new cmd window with the correct path from Cygwin?

When I start cmd.exe from start menu, I get the registered (in registry) PATH variable, in a new window.
I want to have exactly the same effect from my cygwin+mintty, and try the followings:
Firstly I try:
bash$ cmd
This gives me a cmd shell, right inside mintty. But I want it to be in a fresh new window. emm... Perhaps I can try:
bash$ cmd /c start cmd
It nicely gives me a cmd shell in a new window. Good. However, the PATH inside that command shell is not the same as a fresh new one.
C:\>path
PATH=C:\cygwin64\usr\local\bin;C:\cygwin64\bin;C:\ProgramData\Oracle\Java\javapa
th;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\W
indowsPowerShell\v1.0;C:\opencv\myrelease\bin;C:\Qt\5.3\mingw482_32\bin;C:\Progr
am Files (x86)\Skype\Phone;C:\Program Files (x86)\Windows Kits\8.1\Windows Perfo
rmance Toolkit;C:\Program Files\Microsoft SQL Server\110\Tools\Binn;C:\cygwin64\
lib\lapack;D:\home\robin_hsu\bin
C:\>
You can see those paths with cygwin64 are not wanted. So, what can I do to get a new fresh cmd window, with correct PATH?
Note: I believe the problem is due to PATH is inheritable, from bash to cmd.
Perhaps someone can give me some hint to get the registered PATH of windows system under cygwin's bash. If that is possible, I can first change the PATH to the desired one, and then call cmd
So, this is basically a duplicate question to Start new cmd.exe and NOT inherit environment?. However, that question doesn't ask to open a new window, and at least for me the answers there didn't give me a correct path. The following command gives both (for me, on XP).
cygstart "$WINDIR\explorer.exe" "$WINDIR\system32\cmd.exe"
The only issue is that it also brings up dialog boxes 'File Download - Security Warning' AND 'Windows Explorer - Security Warning'. This link shows how you can avoid this in general, but I'm not sure if it's possible to remove the warnings for just one specific file. There are also a couple of answers here and here on superuser.com about disabling the warnings.
Hope this helps.

why can't I run this exe file from the command prompt?

My file's path is D:\installed software\Wing IDE 3.2\bin\wingide.exe.
Now I want to run the wingide.exe file on the command line. So first, I enter cmd to the startup box, then get C:\Documents and settings\Administrator>
Then I typed d: then installed software\Wing IDE 3.2\bin\wingide.exe after it. and click the enter key. It shows D:\installed is not an command. Why? How can I correct this?
The Windows command prompt (I hope you are not actually using MS-DOS!) does not care about what keys you've typed. It cares about the command you are attempting to run and it seems it's this:
installed software\Wing IDE 3.2\bin\wingide.exe
So you are asking to run program "installed" and pass three parameters to it:
software\Wing
IDE
3.2\bin\wingide.exe
... because that's how most command prompts work: you use white space to separate items. You probably want this:
"installed software\Wing IDE 3.2\bin\wingide.exe"
or:
"D:\installed software\Wing IDE 3.2\bin\wingide.exe"
Your path has a space in it so you need to put quotes around it. Try typing:
"D:\installed software\Wing IDE 3.2\bin\wingide.exe"
Type:
"D:\installed software\Wing IDE 3.2\bin\wingide.exe"

Why is Windows 'Run:' different from CMD line?

When I type 'http://www.google.com at the Windows Run: prompt it launches my default browser.
But when I do it at the CMD or Commnad prompt it does not. I assume that there is some form of RunDLL command being issued but I can't find out what.
Does anyone have any insight?
I think it's the equivalent of using START.
If you try
START http://www.google.com
from the command line (or a batch file), it should work fine.
What Jon said appears to be correct. I tested it with mailto:someone#somewhere.com. Interestingly if you wish to make run work like the default behaviour of cmd, you can do the following:
Start -> Run -> cmd /c http://www.google.com. Not sure why anyone would ever need to do that though!

Open a file from Cygwin

Is there an equivalent to OSX open command in cygwin. open opens a file with the default application for that type.
I want to do something like
$ magic-command file.xls
#excel opens as if file.xls would have been double-clicked
$ magic-command file.txt
#notepad opens as if file.txt would have been double-clicked
You get the idea?
Basically something like a "cygwin-double-click" command.
You can also use the cygwin utility:
cygstart <your file>
To make things OSX-like add the following to your bashrc
alias open='cygstart'
Don't forget to check out the man page for cygstart.
You can use the start command from the CMD like this:
cmd /c start <your file>
explorer <your file>
works too. What is nice is
explorer .
opens a windows explorer window in the current directory. But then
cygstart .
does the same thing and does more, but I find 'explorer' slightly easier to remember.
I am using Cygwin in Win7. I can run file on windows through ccygwin command line.
cygstart <your file>
when you run this command your file will open in windows.
Under the Windows command-line interpreter (cmd.exe) there is support for the start command. I know of somebody who implemented start in cygwin. You can find the page about it here.
You could also simply call cmd.exe (usually located in /cygdrive/c/windows/system32/cmd.exe) with the following arguments cmd /c "start yourfile.file"
If, like me, you are using putty to ssh locally on your windows machine to Cygwin as cmd.exe is a terrible console, you may want to change your sshd service to allow it to access the local desktop (this will only work on certain windows flavors) under the sshd windows service Logon properties.
Yes, there is an equivalent to Windows, try with xdg-open <your file>

Resources