Jump to content

Setting Environment Variables in PE without startnet.cmd


yogger

Recommended Posts

Is there a way to set environment variables (specificaly temp) other than using the 'set' command through startnet.cmd?

I'm working on a custom program and I would rather run it with winpeshl.ini than leave startnet open

Link to comment
Share on other sites


Sure; one of two ways:

Method One: Manual process

Open up REGEDIT on your computer, click on HKEY_LOCAL_MACHINE, click on the File menu, click on Load Hive... Browse to the folder where you have your PE files, go into the I386\System32\Config folder. Double click on the "Default" file, give it a name of zzz_default when it prompts.

Expand the zzz_default key, click on the Environment key, double-click the TEMP value in the right pane and fill in your requested path. When finished, go back to the left pane tree view, click again on zzz_default, and now you can click File and Unload Hive.

Method two: Automated process

Go into your actual PE build files where all the ODK stuff is actually stored. Double-click on the file named "Winpedef.inf" and it should open in Notepad. Under the [AddReg] section, copy in the following line:

HKCU,"Environment", "TEMP", REG_EXPAND_SZ, "<temppathyouwant"

Save the INF file. Next time you build a PE image with your MKIMG command, that registry key will automatically insert itself. Obviously this doesn't "fix" any existing PE images you've already built.

Link to comment
Share on other sites

Thanks. I am trying method one, I have all the files on my HD, full control of the files, and read only turned off but I get an error opening key. Am I doing something wrong?

I can't try method two right now because I don't have access to the original files, I'm taking over someones position and don't have time to rebuild from scratch (just start and they want something next week....)

Link to comment
Share on other sites

What is the error you receive when trying to open the default file with Regedit?

I'm able to open it in regedit and it shows up under hklm. But when i click on it I get a message: "cannot open zzz_default: error while opening key"

Link to comment
Share on other sites

I figured it out. the permissions on the key were borked. I redid the iso and tried to run my app, but it's still erroring out until i manually do a set command. I double checked the registry hive and both temp and tmp point to where i want them but nothing shows up when i do a set.

Link to comment
Share on other sites

Try to set the reg keys here: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment

This should solve your problem. To add some value, before burning your iso, do:

-launch regedit

- go to HKEY_LOCAL_MACHINE

- do file, load hive, select setupreg.hiv which should be in I386\system32 folder

- set a name as you like for example sys.

- now go to HKEY_LOCAL_MACHINE\SYS\ControlSet001\Control\Session Manager\Environment

- add the value like Albuquerque described.

Link to comment
Share on other sites

Try to set the reg keys here: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment

This should solve your problem. To add some value, before burning your iso, do:

-launch regedit

- go to HKEY_LOCAL_MACHINE

- do file, load hive, select setupreg.hiv which should be in I386\system32 folder

- set a name as you like for example sys.

- now go to HKEY_LOCAL_MACHINE\SYS\ControlSet001\Control\Session Manager\Environment

- add the value like Albuquerque described.

Thank you, that did the trick. :thumbup

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...