Windows BATCH "Can't Find the File Path" - windows

So I was wanting to create a small batch file which runs a command line dialogue and launches various programs when my computer starts up. More for fun then practical uses really. My problem is that windows doesn't seem to be able to find some files despite my opening the file path in command prompt itself and copying the file path. It just gives me a "The system cannot find the file specified error."
Here's the relevant code for the batch file now edited for better readability (sorry about that):
//Works
start "" "C:\Program Files\Rainmeter\Rainmeter.exe"
//Also works
"G:\Steam\Steam.exe"
//Everything below this fails
"C:\Program Files(x86)\Google\Chrome\Application\chrome.exe"
"C:\Program Files(x86)\Razer\Synapse\RzSynapse.exe"
"C:\Program Files(x86)\eclipse\eclipse.exe"
"G:\Steam\steamapps\common\AdVentureCapitalist\adventure-capitalist.exe"
The first two files, rainmeter and steam, open fine, but everything past that fails. I've tried using both "Filepath" and start "" "Filepath", but neither seems to work. despite both working in the code above.
And, just to clarify, I have double and triple checked the file paths to make sure I didn't get something wrong, but it's just not working.
Thanks for any assistance that can be provided.

If you can provide which ones doesn't open it would be great.
"C:\Program Files(x86)\Google\Chrome\Application\chrome.exe"
Just like how people mentioned in your post comment there should be a space in between Program Files and (x86)
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
Feel free to make use of env variables.
%programfiles% ==> C:\Program Files
%programfiles(x86)% ==> C:\Program Files (x86)
"%programfiles(x86)%\Google\Chrome\Application\chrome.exe"

Related

Making a script to open, configure, and run multiple programs sequentially

While I have experience coding in Java and c++, I have never scripted anything and would like to learn. I want to create a script or a program which:
Opens Avast Virus Scanner
-deep scans
-quits upon being completed
Opens Malwarebytes
-same as above
opens Spybot Search & Destroy
-same as above
Shuts down computer
I honestly don't know where to even start - should I use a batch file or something else? I would appreciate any help. Thanks
This is only a partial answer, but in order to open programs, you can write a batch file. I found this guide: http://www.online-tech-tips.com/computer-tips/create-windows-batch-files/
#echo off
start "Chrome" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
start "Notepad" "C:\Program Files (x86)\Notepad++\notepad++.exe"
start "VS2012" "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
start "Outlook" "C:\Program Files (x86)\Microsoft Office\Office14\outlook.exe"
Technically you don't have to touch coding. This can be done through "scheduling" or through some free software. Is it completely necessary to do the coding yourself?

Windows CMD: How to create symbolic link to executable file?

My goal is to add a few executables to my PATH (for example, chrome), so that I can call
> chrome
from the command prompt and it will launch Chrome.
I know I could add Chrome's containing directory to my path (set PATH=%PATH%<chrome_path_here>;), but since I have a few executables I want to add, I'd rather make a new bin directory that contains symbolic links to the actual executables and just add that single directory to my PATH.
The Chrome executable is located at
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
So I tried
> mklink chrome.exe "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
That successfully creates a symbolic link for the files (says so in output, and upon examining with > dir). I know my PATH is set up correctly, b/c when I run > where chrome it finds my new symbolic link.
However, when I try to execute chrome with my new link, nothing happens. A new empty window should appear, but nothing happens. No error message in the command prompt or anything.
What am I doing wrong? Am I misunderstanding symlinks in Windows? This is the approach I use in Linux all the time, but I'm new to Windows Cmd.
Thanks!
Most programs will not run from places other than they install location - which is exactly what happens when you try to run it from symlink.
It would be much easier to create CMD/BAT files in that folder with matching names which will launch programs from locations you want:
REM chrome.cmd
start /b cmd /c "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" %*
With Windows 7 I confirm that symlinks do not work, are simply ignored as reported in the original question.
As Harry states in his comment, shortcuts do work, and to me are simpler and easier than writing a separate script for each new command I want to enable under CMD.
He states that you need to add .lnk to your PATHEXT variable in order to do this. I affirm that this does work, and with .lnk added to PATHEXT I can simply enter the name portion of the shortcut to run the command. For example if my shortcut is named "sublime.lnk" and PATHEXT includes .lnk, I can execute the link with the simple command "sublime". Nice!
As an alternative I found that PATHEXT need not be modified if I simply type in the full name of the shortcut, including the .lnk, at my CMD prompt. E.g., I created a shortcut named "sublime.lnk" under %HOMEPATH%/bin, pointing to "C:\Program Files\Sublime Text 2\sublime_text.exe".
Now by placing %HOMEPATH%\bin in my %PATH% I can run sublime via the command "sublime.lnk".
Either of the above are the best way I know of giving access to various commands from around Windows' filesystem from a CMD prompt. I'm not a Windows expert though, and welcome a better or more standardized solution to this problem.
P.S.: I just found out the hard way that you need to ensure the "Start in:" property of any shortcut you use in this fashion is blanked out, or your program will not start in the directory you invoke the shortcut from.
P.P.S.: On a related note, I discovered how to run Windows Explorer (or its replacement) on the directory your CMD session is logged in to: start ..

can't execute cvs command in DOS in windows 7

When cvs is typed in cmd.exe in windows 7 nothing is output. The path of the cvs is already in the PATH :C:\Program Files (x86)\CVSNT\; When typing "C:\Program Files (x86)\CVSNT\cvs" there are outputs there. But when other .exe e.g. calc is typed the corresponding program can be executed. Any idea?
This might sound like a strange suggestion, but try cvs.exe instead of just cvs. Without specifying an extension, your operating system will search for the first file that matches the name, cvs. If it happens to find cvs.bat in one of your paths, then it will execute the .bat file instead of the.exe.
If you have cvs.bat , cvs.com, and cvs.exe within the same directory. The order of precedence would be the following:
cvs.com
cvs.bat
cvs.exe
I have a strong suspicion that there's a blank cvs.bat file hidden somewhere in one of folders defined in your path variable, and that you are actually running this batch file when you type cvs.
HI the answer is Run the exe with full path like "C:\Program Files (x86)\CVSNT\cvs.exe" followed by CVS arguments like -q Checkout.....

Why does 7zip Ignore my InstallPath when making a SFX installer?

Currently, I am making a SFX with 7zip using the following config:
;!#Install#!UTF-8!
InstallPath="C:\\test"
GUIMode="2"
RunProgram="7z465.exe"
;!#InstallEnd#!
I then package 7z465.exe into Setup.7z, and then call the following line in a batch file:
copy /b "C:\Program Files\7-Zip\7zSD.sfx" + config.txt + ".\Release\Setup.7z" .\Release\Setup.exe
When I run the resulting Setup.exe, It extracts fine and launches the 7z465.exe as well, but it is still extracting to some 7zip temp folder for the current user and not C:\test!
Running as administrator seems to have no effect either.
Anyone have any idea why this is happening?
Use modified 7zsd.sfx from http://7zsfx.solta.ru. InstallPath only works with the modified package.
I never found out why this was happening, and after hours of struggling with it, I switched to WinRAR. Granted, its got some quirks of its own, but I was at least able to figure those out and get it running for my needs.
Would recommend WinRAR over 7z for SFX stuff.

How do I specify C:\Program Files without a space in it for programs that can't handle spaces in file paths?

A configuration file needs position of another file,
but that file is located in "C:\Program Files",
and the path with space in it is not recognized,
Is there another way to specify the location without space in it?
you should be able to use
"c:\Program Files" (note the quotes)
c:\PROGRA~1 (the short name notation)
Try c:\> dir /x (in dos shell)
This displays the short names
generated for non-8dot3 file names.
The format is that of /N with the
short name inserted before the long
name. If no short name is present,
blanks are displayed in its place.
Never hardcode this location. Use the environment variables %ProgramFiles% or %ProgramFiles(x86)%.
When specifying these, always quote because Microsoft may have put spaces or other special characters in them.
"%ProgramFiles%\theapp\app.exe"
"%ProgramFiles(x86)%\theapp\app.exe"
In addition, the directory might be expressed in a language you do not know. http://www.samlogic.net/articles/program-files-folder-different-languages.htm
>set|findstr /i /r ".*program.*="
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
Use these commands to find the values on a machine. DO NOT hardcode them into a program or .bat or .cmd file script. Use the variable.
set | findstr /R "^Program"
set | findstr /R "^Common"
Use the following notations:
For "C:\Program Files", use "C:\PROGRA~1"
For "C:\Program Files (x86)", use "C:\PROGRA~2"
Thanks #lit for your ideal answer in below comment:
Use the environment variables %ProgramFiles% and %ProgramFiles(x86)%
:
I think the reason those suggesting using the C:\PROGRA~1 name have received downvotes is because those names are seen as a legacy feature of Windows best forgotten, which may also be unstable, at least between different installations, although probably not on the same machine.
Also, as someone pointed out in a comment to another answer, Windows can be configured not to have the 8.3 legacy names in the filesystem at all.
There should be a way to use the full c:\program files path directly. Often, it involves encapulating the string in quotes. For instance, on the windows command line;
c:\program files\Internet Explorer\iexplore.exe
will not start Internet Explorer, but
"c:\program files\Internet Explorer\iexplore.exe"
will.
The Windows shell (assuming you're using CMD.exe) uses %ProgramFiles% to point to the Program Files folder, no matter where it is. Since the default Windows file opener accounts for environment variables like this, if the program was well-written, it should support this.
Also, it could be worth using relative addresses. If the program you're using is installed correctly, it should already be in the Program Files folder, so you could just refer to the configuration file as .\config_file.txt if its in the same directory as the program, or ..\other_program\config_file.txt if its in a directory different than the other program. This would apply not only on Windows but on almost every modern operating system, and will work properly if you have the "Start In" box properly set, or you run it directly from its folder.
No.
Sometimes you can quote the filename.
"C:\Program Files\Something"
Some programs will tolerate the quotes. Since you didn't provide any specific program, it's impossible to tell if quotes will work for you.
I think that the other posts have answered the question, but just some interesting for your information (from the command prompt):
dir c:\ /ad /x
This will provide a listing of only directories and also provide their "Short names".
You could try to use:
C:\PROGRA~1
As an alternative to the other answers, you can try symbolic links.
Create the symbolic link first and install the application based on the link. (Depending on the case, this may be way easier to do, for instance when the application has n mentions of the target folder throughout its code)
A symbolic link will create something similar to a shortcut to a folder, but seen as an actual folder by other applications.
This is how you do it:
Run cmd as administrator
User this command: mklink /D "C:\LinkToProgramFiles" "C:\Program Files"
And then, you start using "C:\LinkToProgramFiles" in the applications that can't handle spaces. (This link can be seen in Windows Explorer as a folder with the symbol of a shortcut)
Be very careful not to create circular links if you start playing too much with this.
Try surrounding the path in quotes. i.e "C:\Program Files\Appname\config.file"
You can use the following methods to specify C:\Program Files without a space in it for programs that can't handle spaces in file paths:
'Path to Continuum Reports Subdirectory - Note use DOS equivalent (no spaces)
RepPath = "c:\progra~1\continuum_reports\" or
RepPath = C:\Program Files\Continuum_Reports 'si es para 64 bits.
' Path to Continuum Reports Subdirectory - Note use DOS equivalent (no spaces)
RepPath = "c:\progra~2\continuum_reports\" 'or
RepPath = C:\Program Files (x86)\Continuum_Reports 'si es para 32 bits.
Either use the generated short name (C:\Progra~1) or surround the path with quotation marks.
You can just create a folder ProgramFiles at local D or local C to install those apps that can be install to a folder name which has a SPACES / Characters on it.

Resources