Starting a program in command prompt just opens up another command prompt window - command

Does anyone know why when I type the following command in my command prompt, instead of opening the intended program, it just opens up another command prompt window? It's the same if I create a batch file with the command.
start "C:\Program Files\BrokerLink AutoPrint\BrokerLinkAutoPrint.exe"

An extra pair of double quotes "" should make this work as expected:
start "" "C:\Program Files\BrokerLink AutoPrint\BrokerLinkAutoPrint.exe"
START regards the first quoted parameter as the window-title, unless it's the only parameter - and any switches up until the executable name are regarded as START switches.
Alternatively, you could just use:
call "C:\Program Files\BrokerLink AutoPrint\BrokerLinkAutoPrint.exe"

Related

Running PowerShell Script from shortcut with spaces in path

One of our users needs to invoke a PowerShell script from a shortcut, as using the command line is probably beyond their abilities. The path of the script contains spaces, and I have been unable to successfully get the script to run from the shortcut. The target of the shortcut is:
powershell.exe -file "C:\Users\xxxxx\xxxx xxxx\Finance - Documents\Secure\xxx (Finance Officer)\Rent\Data File Loader - XXXXX\InvokeDataLoader.ps1"
(I have replaced names of people and the company with x's)
Clicking on the shortcut just briefly opens a cmd window (I think) so I have have been trying to diagnose the problem by running the command in cmd.exe. However when I try to do that I get an error message that it cannot find the path "C:\Users\xxxxx\xxxx" i.e. it is splitting the path on the first space. Enclosing the path with single or double quotes does not change this, and if I try to escape the spaces with backticks I get a message that the path does not exist.
You actually don't need to change the PowerShell script itself to do this. When making the shortcut, simply set the target to:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "C:\Users\xxxxx\xxxx xxxx\Finance - Documents\Secure\xxx (Finance Officer)\Rent\Data File Loader - XXXXX\InvokeDataLoader.ps1"

perl command prompt with arguments

Is it possible to start a command prompt from perl script using Win32::Process::Create package?
I am trying to start DOORS from perl script. The executable is present in C:\Program Files\DOORS\bin\runDOORS9.rck.
I need to start the runDOORS9.rck with the argument COL9 to change the Database.
Try the good old system() function. On Windows it would use the cmd.exe, the system shell, to execute the command.
Since what you try to launch doesn't seem to be an .exe file, potentially you would have to use the start command of the cmd.exe.
For example:
system(qq{start "" "C:\Program Files\DOORS\bin\runDOORS9.rck" COL9});
(The first "" is required due to quirky argument parsing of the Window's shell commands. See help start for more information.)

psexec not executing command once I pass in command line arguments

I have to run the following command remotely on another server, the arguments are prefixed with !=:
wdrspc.exe !=BATCHTEST1,LGTY_PLAN_01
This works (but the exe fails because I'm not passing in any arguments):
psexec \\kiklogiappsd "c:\Program Files (x86)\Logility\SPC8.0\wdrspc.exe"
This does not work (psexec says system cannot find the file specified):
psexec \\kiklogiappsd "c:\Program Files (x86)\Logility\SPC8.0\wdrspc.exe !=BATCHTEST1,LGTY_PLAN_01"
I'm stumped, is it the != syntax throwing off psexec?
The correct command line would be:
psexec \\kiklogiappsd "c:\Program Files (x86)\Logility\SPC8.0\wdrspc.exe" !=BATCHTEST1,LGTY_PLAN_01
The program arguments should not be in quotes with the program path, or they'll be interpreted as part of the program path. When you quote a space in a command line argument, that tells the shell that the space is part of the argument, rather than separating two arguments. That's why you quote anything in C:\Program Files (x86). But you want an argument-separating space between the program path and its arguments.

Batch start command not opening program

When I enter the following from a command prompt:
start myprog.exe
It opens the program in a command window, but it doesn't start the actual program itself.
Does anyone know what I'm doing wrong with this?
try this:
start /b "" "myprog.exe"
See start /? for more help.
You don't need START just have myprog.exe, make sure that the program can be found. Put the directory for it in the PATH environment variable if necessary.
If you want to continue processing more commands in the batch file use the /B switch for START, see syntax here Microsoft DOS start command.

From command line on win7, how do I launch a process as administrator with elevated UAC

I have a program which requires Administrative privileges that I want to run from a batch file. What command can I run from command line will run my program with administrative privileges? I'm okay with the pop-up window asking for permission. Additionally, the file needs to be able to run from anywhere on a computer so additional files are run from ./src. The problem is that if I right-click and choose "run as administrator" it changes my current directory so ./src no longer works. If I disable UAC on my machine then everything runs fine. Thank you!
Look here: https://superuser.com/a/269750/139371
elevate seems to be working, calling
C:\Utils\bin.x86-64\elevate.exe -k dir
executes dir in the "current directory" where elevate was called.
This is tough, Microsoft provides no utility to do this (mostly because giving a batch file that ability breaks security), except for RunAs, and that requires that the Administrator account be activated.
There IS a JScript program that can do something similar, by using SendKeys to open the Start menu and type cmd[CTL]+[SHIFT]+[ENTER] which will launch a Command-Line shell.
Save the following as as .js file, like StartAdmin.js:
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys("^{esc}cmd^+{ENTER}"); The equivilent of [CTRL]+[ESC] cmd [CTRL]+[SHIFT]+[ENTER]
To run StartAdmin.js from a batch file, you will need the following line:
wscript StartAdmin.js
To launch from a particular directory and launch a batch file, change line 2 in StartAdmin.js to something like:
WshShell.SendKeys("^{esc}cmd /C "cd %userprofile% & batchfile.bat"^+{ENTER}");
/C switch tells it to run the commands, then close the command-line window.
/K would leave the command window open after it exited the batch file.
To help you understand the SendKeys commands:
+=[Shift Key]
^=[Control Key]
{esc}=[Escape Key]
{enter}=[Enter Key]
To learn more about using CMD.EXE, type CMD /? at the command prompt.
This is a very untidy and ugly way to do it, but it's the only way I know how using only the tools that come with Windows.