I want to support two versions of a Windows app easily.
It uses environment variables to configure it.
I'd like to set up a top level ENV, that can be changed to switch versions:
VERSION_ROOT = c:\tool_version_A
TOOL_BIN_FOLDER = $VERSION_ROOT\bin
TOOL_LIB_FOLDER = $VERSION_ROOT\lib
Then if I need to switch to tool version B, I just change the VERSION_ROOT environment variable: VERSION_ROOT = c:\tool_version_B
and I'm done.
Any way to make this work in Windows?
Durn it! No - When I put %TOOL_BIN_FOLDER% in the Windows 10 environment variable edit box it IMMEDIATELY expands it to the folder location, replacing the variable with the hard wired path #facepalm.
This didn't work:
Trying to use the Windows batch file variable synth with the surrounding % signs:
TOOL_BIN_FOLDER = %VERSION_ROOT%\bin
More hints here: Limits on Windows environment variable nesting?
Related
I have a program in which I use a lot "../" which is to go one level up
in the file system and run some process on the directory with specific name. I have a command line tool in Go.
I have 3 questions
there is nicer way to do it instead of “../“
is there a const with which I can use instead of “/“
if 2 is not available should I create “constants“ under that internal package to share the “/“ between packages since I need it in
many place (from diff packages...)
example
dir.zip("../"+tmpDirName, "../"+m.Id+".zip", "../"+tmpDirName)
Set a variable, and use that everywhere:
path := "../"
or
path := ".." + string(os.PathSeparator)
then later:
dir.zip(path+tmpDirName, path+m.Id+".zip", path+tmpDirName)
This makes it very easy to change the path in the future, via a command line option, configuration, or just editing the value.
Yes. os.PathSeparator is the OS-specific path separator for the current architecture.
n/a
declare a global const somewhere, but I would just use ".." everywhere
os.PathSeparator
use filepath.Join("..", someDir, someFilename)
I have a very simply (maybee very stupid) question regarding the Windows 7 (Path)-Variables.
Until Windows 10 the Gui looks very ugly und uncomfortable (short Textboxes for large Inputs) I Use custom variables to short down my view.
For example:
envi -->C:\Program Files (x86)\MiKTeX 2.9\miktex\bin;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\TortoiseSVN\bin;
So I can use it in path like this:
path -->"[...];%envi%;"
Now I tried to do the same with the default settet part end extract the following:
sys --> %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\;
But THAT does not work:
path --> ;%sys%; %envi%; [...]
even if I type "echon %sys%" it seems ok. But if I type "echo %path% it will resolve every variable instead of %sys%.
Now my question:
Is that impossible coursed by nested variables (%sys% contains %SystemRoot%?)
Or may there be another problem?
Greatings Oekel
I'm using Lua in interactive mode on a Mac (thanks to rudix.org).
When I want to load a file I do:
dofile("/my/long/path/to/my/directory/file.lua")
I want to do a different thing, that is:
put all my files in a desktop directory myDirectory;
then call the file from the terminal this way dofile("file.lua");
Is this possible? How?
If the path is fixed, you can just redefine dofile:
local _dofile=dofile
local path=("/my/long/path/to/my/directory/")
function dofile(x)
return _dofile(path..x)
end
You may put this (and other initializations) in a file and set the environment variable LUA_INIT to its location. After this, every invocation of lua will see the version of dofile redefined above and the users will be able to say simply dofile("foo.lua").
Alternatively, you can use require, which looks for modules in a list of paths in package.path or LUA_PATH.
The Xcode archive step creates this variable: ${BITRISE_DEPLOY_DIR} and read that pilot uses the PILOT_IPA environment variables for the IPA directory.
Is there a way to assign the output (BITRISE_DEPLOY_DIR) to another environment variable (e.g.: $PILOT_IPA)?
You can do that by using envman (https://github.com/bitrise-io/envman) which is part of the bitrise CLI tool stack.
To assign the value of an existing Environment Variable (Step outputs are just regular Environment Variables) you can use a Script step, and specify this as the content:
#!/bin/bash
echo "BITRISE_DEPLOY_DIR: $BITRISE_DEPLOY_DIR"
envman add --key PILOT_IPA --value "$BITRISE_DEPLOY_DIR"
This'll first print the value of the BITRISE_DEPLOY_DIR environment variable, and then with envman add it'll add a new environment item with the key PILOT_IPA and the value of $BITRISE_DEPLOY_DIR.
I am trying get the parent folder of a Windows user's profile path. But I couldn't find any "parameter" to get this using SHGetSpecialFolderPath, so far I am using CSIDL_PROFILE.
Expected Path:
Win7 - "C:\Users"
Windows XP - "C:\Documents and Settings"
For most purposes other than displaying the path to a user, it should work to append "\\.." (or "..\\" if it ends with a backslash) to the path in question.
With the shell libary version 6.0 you have the CSIDL_PROFILES (not to be confused with CSIDL_PROFILE) which gives you what you want. This value was removed (see here), you have to use your own workaround.
On any prior version you'll have to implement your own workaround, such as looking for the possible path separator(s), i.e. \ and / on Windows, and terminate the string at the last one. A simple version of this could use strrchr (or wcsrchr) to locate the backslash and then, assuming the string is writable, terminate the string at that location.
Example:
char* path;
// Retrieve the path at this point, e.g. "C:\\Users\\username"
char* lastSlash = strrchr(path, '\\');
if(!lastSlash)
lastSlash = strrchr(path, '/');
if(lastSlash)
*lastSlash = 0;
Or of course GetProfilesDirectory (that eluded me) which you pointed out in a comment to this answer.