📎 AI Summary:
The thread discusses how to temporarily set environment variables for applications like Android Studio Portable without administrative access, especially in a school setting where such changes are restricted. The original poster asks if it's possible to define a one-time environment variable for a specific app, and it is suggested that creating and running a batch file can achieve this if command prompt access is available. However, a later comment notes that batch files run within cmd.exe, which may be blocked, limiting the effectiveness of this method in their school environment. Overall, the conversation highlights potential workarounds for environment variable management despite restrictions, but also acknowledges limitations due to system controls.

Guest21

New Member
Joined
Apr 24, 2018
Messages
22
Thread Author #1
First of all, here is how I got here. I migrated from Microsoft Community because they now tell me to verify using a phone number which I don't have. So, I searched 'windows forums' and found this, so I will be using this website for all my Windows needs from now on.

Anyways, now to my question. I have heard that changing some environment variables around helps some applications work. I wanted to try Android Studio Portable in school, but I ran across an error saying I need to provide an environment variable for JDK which I already have), but I don't have access to those. I knew I needed to change environment variables in order for it to work before, but I can't do it as I want to try it in school. So, is it possible to define a custom, one-time variable to only Android Studio Portable without the need for actually changing it in the Control Panel? Also, I am referring to a way which does not require admin access, because I have none in school. If such a feature doesn't exist, maybe someone can invent one that sets a one-time variable to Android Studio Portable?

Just to let you know, I am posting this from Windows 10 Home at home, but I want to try it on Windows 7 Enterprise at school.
 

Solution
Yes, if you need to change an existing variable you can see what you have available by typing

Get-ChildItem ENV:

and set a variable with
In the example I'm setting the existing environment variable TEMP to hello
Set-Item ENV:\TEMP -Value "Hello"

In this example I'm just creating a new variable called T
Set-Item Env:\T -Value "Hello"

You can then run a program with
Start-Process pathtoprocess\process.exe

Neemobeer

Windows Forum Team
Staff member
Joined
Jul 4, 2015
Messages
8,995
Yes you can temporarily change them. Create a batch file (.bat)

SET VARIABLENAME=VALUE
START processname, it should be set to the new value for that instances
 

Guest21

New Member
Joined
Apr 24, 2018
Messages
22
Thread Author #3
Yes you can temporarily change them. Create a batch file (.bat)

SET VARIABLENAME=VALUE
START processname, it should be set to the new value for that instances
Can't wait to try it out. But does it work on school computers? I am eager to try it out in school, but I am not allowed to change variables (can access bat files though). And can you please provide an example of this, I am unsure what to do with the basic information you have given me.
 

Neemobeer

Windows Forum Team
Staff member
Joined
Jul 4, 2015
Messages
8,995
As long as you can open a command prompt and run a batch file then yes it should work.
 

ussnorway

Windows Forum Team
Staff member
Joined
May 22, 2012
Messages
4,598
in most senarios a school system will dump any temp data once you sign out at the end of class so you will need to re-run this batch at the start of each new class
 

Neemobeer

Windows Forum Team
Staff member
Joined
Jul 4, 2015
Messages
8,995
A variable set in this fashion will only exist as in the command prompt where it's set. If you open another command prompt it will have the old variable in it.
 

Guest21

New Member
Joined
Apr 24, 2018
Messages
22
Thread Author #7
As long as you can open a command prompt and run a batch file then yes it should work.
Well yeah, its blocked (AT SCHOOL BUT NOT AT HOME) but I have a batch file which allows me to enter commands. Will this work when I am in school? (I have uploaded it as a text file so you can see if it can work with this)
 

Attachments

Guest21

New Member
Joined
Apr 24, 2018
Messages
22
Thread Author #8
in most senarios a school system will dump any temp data once you sign out at the end of class so you will need to re-run this batch at the start of each new class
I don't know ... maybe I can try to see if it works using my (otherwise) made up CMD, which maybe might not work anyways. See the attached file for my reply to Neemobeer for the file.
 

Guest21

New Member
Joined
Apr 24, 2018
Messages
22
Thread Author #9
A variable set in this fashion will only exist as in the command prompt where it's set. If you open another command prompt it will have the old variable in it.
Command prompt is blocked at school. But maybe my own batch file could work to replace CMD.
 

Neemobeer

Windows Forum Team
Staff member
Joined
Jul 4, 2015
Messages
8,995
No batch files execute from conhost which launches cmd.exe
 

ussnorway

Windows Forum Team
Staff member
Joined
May 22, 2012
Messages
4,598
does the school allow v-systems like vmware or hyper-v... you can use them to get a cmd prompt
 

Guest21

New Member
Joined
Apr 24, 2018
Messages
22
Thread Author #12
Ok, new question. Can I set a one-time variable to run an application in Powershell? For my COMMAND batch script, it does (appear to) set an environment variable, but when I call the .exe from the window, it doesn't work.
 

Neemobeer

Windows Forum Team
Staff member
Joined
Jul 4, 2015
Messages
8,995
Yes, if you need to change an existing variable you can see what you have available by typing

Get-ChildItem ENV:

and set a variable with
In the example I'm setting the existing environment variable TEMP to hello
Set-Item ENV:\TEMP -Value "Hello"

In this example I'm just creating a new variable called T
Set-Item Env:\T -Value "Hello"

You can then run a program with
Start-Process pathtoprocess\process.exe
 

Solution