Windows custom system variables in save/open boxes - windows

For many years I've been using the windows custom system path to mapping folders and files to be accessible through RUN box. I put the main folder path in the PATH field of Environment Vars and so I can type the subfolder name in the RUN and access it.
Environment Vars:
Per example, I can type "cronos" in the RUN box and access a folder with this name, within "b:\wampp\www". I would like to use these variables in the Windows Explorer, on save / open boxes, in the same way that the %USERPROFILE% and %PATH% variables are used. I think that %cronos% should work, but it is not recognized.
var on save box:
Has anyone used the vars in this way? Any idea? Thanks.

To use it in this way, you need add "cronos" full path to Path variable in your system, and to do the same with all vars that you want.

Related

Can i set startup folder of tfileopendialog to a shell (non file system) folder?

Can i set startup folder of tfileopendialog to a shell (non file system) folder, and how? If not, is there other way to save the full dialog state for the next call of the application?
Ok if no one will bother answering i will.
dialog.shellitem.getdisplayname(SIGDN_DESKTOPABSOLUTEPARSING,pch);
assigns "::{guid}\..." value to pch variable, and this string can be used to set dialog.defaultfolder or dialog.filename. it can also be used in conjunction with
shellfolder.getdisplaynameof(pidl,SHGDN_FORPARSING,strret);
to identify a folder.

Create startup folder - Windows

I script a lot of things to manage the computers in my company. I often need to add shortcuts into the personnal startup folder of users (without a GPO).
Windows 8/8.1 doesn't have a personnal startup folder by default.
Its location is C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\
It is easy to create this folder, but it needs a desktop.ini file into it, with the correct content, for the name to be localised (else it is displayed "Startup" whatever the language).
What is the "official" way to create this folder?
Or what is the official way to add something into it?
I'd prefer a PowerShell or batch command, but whatever reliable mean is okay.
I guess you can do something with the ComObject for this special folder:
$startup = (New-Object -ComObject Shell.Application).NameSpace(0x07)
By the way, if I enter shell:startup in a run box (Win+R) on my Win 8.1 system, it directs me to my personal startup folder (C:\Users\User\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup).
As far as I know, there is no reliable way to do this.
You can get the path with [environment]::getfolderpath("Startup") but the returned string is empty if the folder was neve created. And I don't know any API entry to create it.
So you have to manually create it:
check if the former command return anything (if yes, just create you shortcut)
create yourself the startup folder. Use [environment]::getfolderpath("StartMenu") and add \startup to the path
then create the desktop.ini file and populate it yourself
and update the registry HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders (I didn't check if this is the right place. [environment]::getfolderpath("Startup") must return the right value)
UPDATE: I just found SHGetKnownFolderPath API which allow to create the required folder if needed (with dwFlags). I'm not good at PowerShell, so I don't know how to call this. Maybe Someone can give a better answer.

How do I add Ruby to the PATH variable on Windows?

I have Ruby installed, but I still need to add it to the PATH variable. I found something online for how to manually add it using the command line:
set PATH=C:\Ruby200-x64\bin;%PATH%
But before I try it, I want to be sure it's not going to overwrite what's currently in the PATH variable. (I have no experience with this stuff so I don't know what to expect).
Thanks in advance for your help!
first, notice that this question is not really about Ruby, rather about how to set a path in windows (it work the same way if you want to add an executable different from Ruby)
second, you are not overwriting the PATH environment variable because you add the existing content of the same to the new one you are setting in:
set PATH=C:\Ruby200-x64\bin;%PATH%
the %PATH% is the current content of the PATH variable.
Consider using
set PATH=%PATH%;C:\Ruby200-x64\bin
instead, this will make your OS search the original path before searching the ruby bin folder. Maybe it makes few difference on modern computers, but my old DOS days claim the second solution is better.
third and last point, in Windows you can set environment variables in control panel / system properties
How to get there depends on the version of your OS, but if you search for the ambient variables and system variables you should get there.
From the Desktop, right-click the very bottom left corner of the screen to get the Task Menu.
From the Task Menu, click System.
Click the Advanced System Settings link in the left column.
In the System Properties window, click on the Advanced tab, then click the Environment Variables button near the bottom of that tab.
In the Environment Variables window (pictured below), highlight the Path variable in the "System variables" section and click the Edit button.
Add or modify the path lines with the paths you want the computer to access. For ruby it will be:
;YOUR_RUBY_INSTALLATION_PATH\bin;
The operation with set PATH=C:\Ruby200-x64\bin;%PATH% is probably only temporary until you restart your computer.
I just wanted to let everyone know that when you install rubyinstaller on Windows and follow its steps, there is no option to 'add to path variables' because it automatically adds it.
Rubyinstaller trolled me hard because it said gem not found when I did gem install sass immediately after install.
Your path variable is probably already set if you used rubyinstaller.
The trick is to open CMD or I would imagine, PowerShell, ConEMU, etc, git bash, and type gem.
Press WINKEY and type cmd
Type gem install sass (or whatever else that is in the bin folder for Ruby)
I just went to add the PATH variable, and it was already set, so my problem was the garbage command line tool that opened after installing rubyinstaller.
You can also do these steps to add to the PATH variables:
Press WINKEY
Type view advanced system settings
Open that
Click Environment Variables
Click Path in the list
Click Edit
Check if C:\Ruby24-x64\bin is already there, if so, done
Click New and type in C:\Ruby24-x64\bin
Done
Yes, this is correct. In your example %PATH% will be expanded to the current value of the PATH variable, so this command is effectively adding a new entry to the beginning of the PATH.
Note that calling set PATH will only affect the current shell. If you want to make this change permanent for all shells, the simplest option is to set it as a user variable using the Environment Variables dialog box.
On Windows 8 you can open this dialog by hitting Win+s and searching for 'environment variables'. On earlier versions of Windows you can right-click 'My Computer', choose Properties, then Advanced system settings, then Environment variables. You can create (or update) a PATH variable in the user variables section and add whatever entries you need. These will be appended to the existing system path. If you take this approach you will need to open a new cmd shell after updating the variables.
Fear nothing, What you are doing is prepend C:\Ruby200-x64\bin to the existing %PATH%, this is what the command you posted does.
The path is a list of directories, separated by ;, in which the system will look for the command you execute.
In your case it's:
C:\Ruby200-x64\bin
%PATH%, if you print it on the command line, you'll find it's itself a list of directories separated by ;.
In case you want to make your change permanent, you have to change your PATH sytemwide.
For CLI, as noted elsewhere calling SET on the path variable only acts on the current window and closing it or restarting windows voids the change.
Example the transient Version selected as the answer:
set "PATH=%PATH%;C:\Ruby200-x64\bin"
To correctly set the path permanently in CLI use the path command:
PATH %PATH%;C:\Ruby200-x64\bin
This will persist between CMD windows and after reboots.
I know this is questions has the Windows tag, however it is one of the first DuckDuckGo results for "ruby gems add to path" so I just wanted to add this.
On Linux you can add this line to the end of your .bashrc in order to add it to your path:
export PATH=$PATH:~/.gem/ruby/2.6.0/bin

How to create a custom percent (%) shortcut like %appdata%?

Is it possible?
If so, how?
Can it be done in CMD?
Existing shortcuts examples :
%appdata%
%temp%
%userprofile%
These are environment variables and you can set your own, yes.
You can set them within a script or at cmd prompt with set, and you can make "global" environment variables by going to System Properties/Advanced and clicking the Environment Variables button. Variables added there will be available to all applications. If you have existing cmd windows open, though, they won't get the global variables - you will need to open new windows to make these variables available.
This should help someone
try %AppData%

Where is the path information in DOS saved

I had recently entered set path = c:\TC\bin;%path%. Thereafter entering path got this path = c:\tc\bin;BLAH-BLAH; and it worked. I closed command and reopened it does not work and on checking I get path=BLAH-BLAH; only. The recent addition I made was not present. Any clues? Thanks.
Environment variables are saved in a registry setting.
When you edit an environment variable in a command shell, the change only applies to that command shell (as you found).
If you want to set the path for the whole system you need to set it centrally - in Windows XP you can right click on "My Computer", choose "Properties", "Advanced" then click on "Environment Variables" at the bottom, and similar methods apply to other Windows sytems.
If you want to edit it programmatically you would need to do this through the registry APIs. There are answers about how to do this here: Programmatically modifiy environment variables?

Resources