584,837 active members*
5,103 visitors online*
Register for free
Login
Page 1 of 2 12
Results 1 to 20 of 26
  1. #1
    Join Date
    Feb 2008
    Posts
    553

    Question Windows XP environment variables ?

    Hi everybody,

    Does anyone know how to define/set an environment variable before Windows XP boots & reads the registry information ?

    I want to have an environment variable that is defined/set automatically each time I power On the computer, at pre-boot time before XP wants to read the info from the registry.

    Do you think ti's doable ? How ?

    Please guys, I need your help on this one !

    Thanks !
    cnc2.

  2. #2
    Join Date
    Sep 2009
    Posts
    30
    You can set environment variables in XP via Control Panel -> System. Then choose the "Advanced" tab and there is a button at the bottom to set environment variables. You can set either user variables or system variables. I believe they get stored in the registry and get read as XP loads.

    Is that what you're after? If not, what are you trying to achieve?

    Glenn

  3. #3
    Join Date
    Feb 2008
    Posts
    553
    Thanks Glenn for the fast reply !

    No, this isn't what I was after, I already know how to set "normal" environment variables, but what I want to do is to modify the boot sequence so that it dynamically sets an environment variable BEFORE the registry is read...a bit like launching a small batch program before the system wants to read the registry at pre-boot time.

    Any idea ?

    Thanks !
    cnc2.

  4. #4
    Join Date
    Sep 2009
    Posts
    30
    I think the only other way is to edit the autoexec.bat in the system root folder. This is a real throwback to the days of DOS ... but the file has remained. I believe the contents of this file are ignored by windows except for any SET commands.

    To add a variable you would do something like:

    SET MYVAR=C:\SOMEWHERE\SOMETHING

    I suppose the challenge now would be to have something that changes the variable in the autoexec.bat before launching Windows. I'm not sure if that's possible.

    Perhaps this link will be useful: http://www.tomshardware.co.uk/forum/...5059_35_0.html

    The last post in that link seems an interesting option. I think you could use it to specify a registry entry to run a .bat in the start of the Windows load sequence. Perhaps that would enable you to get the appropriate env vars pre-login:

    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Se ssion Manager\BootExecute

    It's been a while since I wrote .bat files but I seem to recall you can set menu choices which could be used for setting different options.

    Sorry I can't provide an out-of-the-box solution to this and I wish you good luck.

    Glenn

  5. #5
    Join Date
    Feb 2008
    Posts
    553
    Thanks for your help Glenn !

    You've posted some great info, but i realise that i didn't explain well.

    To sum everything: I need to NOT rely on the registry, & this by setting a variable before the boot loader reads the registry, i know this won't be easy because of the importance the registry has...My final goal is to trick the system & make it look for the registry at a different place than usual...a bit like...i make different copies of the registry & at boot time the environment variable is set by a batch file that reads the path i define in a text file(the path to the reg copy i want to load) or instead of reading a txt it'll just call another batch i modify manually.

    I had thought about autoexec.bat but it was a great deception when i read that on Win XP the autoexec.bat was parsed at login time(too late) unlike in Win98 where it is parsed at pre-boot time.

    Thanks Glenn, i really apreciate your help.
    cnc2.

  6. #6
    Join Date
    Sep 2009
    Posts
    30
    I don't think that's possible. MS did away with the DOS OS layer when it got to XP. Now XP IS the OS.

    Last advice is to see what can be done in the boot.ini but I don't think it can be scripted nearly as much as autoexec.bat used to be.

    Perhaps you'll find better software dev advice from another forum rather than here.

    Good luck ...
    Glenn

    PS. You're not doing anything dodgy are you ... circumventing software licensing etc? ;-) I wouldn't want to offer help (well, ... trying to help) if you were!

  7. #7
    Join Date
    Apr 2005
    Posts
    3634
    PS. You're not doing anything dodgy are you ... circumventing software licensing etc? ;-) I wouldn't want to offer help (well, ... trying to help) if you were!
    LOL

    What about a boot CD?

    It will start before the C-drive, If you have the CD setup to start first.
    Free DXF - vectorink.com

  8. #8
    Join Date
    Feb 2008
    Posts
    586
    While this doesn't address your particular situation, I know that anything in the "Start Menu/Startup" subdirectory is run automatically after logging in. If you have a batch file in there, it could set variables at that time. I'd start reading about the Linux boot loaders "grub" and "Lilo" to see if a multi-boot system would do what you want it to, Or VMWare, or some "boot magic" software is available for that purpose.

  9. #9
    Join Date
    Feb 2008
    Posts
    553
    Thanks to every one for the replies !

    Well, I'm not trying anything doggy & I don't intend to defeat the Windows software registration ...etc, cracks for Windows are widely availabe on the net & I don't need to get in that kind of business.

    If I succeed in solving this "little" problem, It'll be possible to use an install of windows & register it as usual, transparently in the system I'm designing, If for some reasons I can't solve this problem then, my system will require a corporate version of windows that doesn't need registration...The wrong thing about the corporate version, is that it will narrow the use of my system to the owners of a corporate version of Windows, making my system away from the reach of the common people.

    On the sysinternals forum I've been told that the paths are coded in the "configuration manager" which is not explained in the "Windows internals 4th edition"...but on a website I've found that it's Ntldr that locates & reads the registry/hives.

    I've found an old post on a forum, talking about reverse engineering ntldr, it said that inside ntldr there's an "embeded" exe, osloader.exe...it would be cool if I could change the paths to suite my needs, but i'm not sure it's doable.

    I would also need to somehow read the mac address of the NIC 0 & include it in the path...it'd be perfect....yea but will require a lot of old programming skills to do it in asembler.

    Ok, if i'll have to reverse ntldr then, my project will remain experimental until Microsoft agrees to make an official patch to implement this freature.

    Any ideas ?

    Thanks !
    cnc2.

  10. #10
    Join Date
    Jul 2005
    Posts
    450
    Have you considered the windows embedded version of XP. Its cheaper per licence then XP retail, and doesnt require authentication as its designed for embedded systems. Also you can highly customise the image. There is a free 180 day trial available from microsoft if you want to give it a try.

  11. #11
    Join Date
    Feb 2008
    Posts
    553
    Thanks for the reply daedalus !

    I heard about XPE when I was looking for an enhanced write filter for XP & found it was only available for XPE.

    But, why is XPE cheaper than the retail XP ?
    Is there any difference for the common office employee, in using XPE ? Maybe hardware limits ? Network limits ? What about ActiveDirectory & XPE ? Ms Office ...etc ?

    How many people are using XPE ?

    Thabks !
    cnc2.

  12. #12
    Join Date
    Jul 2005
    Posts
    450
    XPE is designed for embedded applications, such as when OEMs ship a piece of hardware with XP preinstalled under the hood.

    The main difference is you can customise XPE images a lot more than XP, but its not really designed for 'office environments'. The embedded products are usually a little cheaper to encourage people off linux solutions for the same problem. Its mainly used in things like kiosks, newer vending machines, Point of Sale machines, bank ATMs, etc.

    It would help if you describe exactly what your trying to do. When you mention installing windows without having to register / set up, is this just a user annoyance issue, or something else (like not being networked when this happens)?

    Are you selling hardware to people that has windows installed on it? If so could you sell with MS preinstalled?

    EDIT: i realised i didnt really answer your question. Hardware, network, AD, etc is all similar to normal XP. As for users, although it doesnt get a lot of press, the embedded line is in a LOT of products, you just dont normally notice it as most OEMs put a pretty shell over the top. Kind of like the popularity of CE.

    Regards,
    Tom

  13. #13
    Join Date
    Feb 2008
    Posts
    553
    Thanks for the reply Tom !

    Sorry I've been off line for a few days.

    No, I'm not selling hardware ..etc I'm a student, working on the final project of my curriculum.

    What I exactly need, is to have say, two copies of the hives stored in, say %path1%\copy\ & %path2%\copy\ ...etc. when the system boots it sets %pathX% accordingly to the NIC's mac address...if mac==mac1 set path to %path1%\copy\ & load the hives/registry from there...etc.

    The rest of the system (the whole system, not XP) is a bit more complex than this.

    Any idea on how to do it ? (without old school reversing the ntldr, which might be hard)

    Thanks !
    cnc2.

  14. #14
    Join Date
    Jul 2005
    Posts
    450
    Thats really quite a nasty problem, and its not just reverse engineering ntldr, you would need a heavily customised bootloader to run before ntldr with code to read the mac address out of the network card without an OS available, which isnt easy even if you fix the network card bus / manufacturer. Add to that you need ntlm support to do the meddling, and its not really practical.

    You could look at winPE, which is a stripped down copy of windows that is used for microsoft install cds. It can be scripted, has basic network support, and can mount the registry of the host pc. You *might* be able to piece together a script that boots winPE, checks the mac, makes the registry changes, then reboots.

    The trick would be having your boot.ini set up to load the PE partition first, do the script, then modify boot.ini back to normal and reboot.

    you would then have to have some software running in the host OS to change boot.ini back to point to your PE partition for next time.

    Downside is you have an extra soft boot each turn on, benefit is its a lot less work. If its for uni i guess these kinds of things can be explained away as it being a prototype.

    Here is a link to a blog post, which links to the download locations for v2, it is free to use, but dont expect miracles by way of documentation
    http://blogs.msdn.com/winpe/archive/...eta-2-now.aspx

    PS: there may be ways of doing this without the reboot, but nothing easy springs to mind

    Best of luck,
    Tom

    EDIT:

    If you can describe you actual application for this there might be far better ways of approaching the problem.
    If you dont need direct hardware access from the XP copy booting, and you can take a small performance hit, you could solve this whole mess in userland code by using a virtualisation technology, such as Vmware or ms virtual pc. You can mount the virtual pcs drive, tamper with the registry, then boot it. That way you dont have to mess with low level hacks, and can spend your time on better things.

  15. #15
    Join Date
    Feb 2008
    Posts
    553
    Thanks for the reply Tom !

    Everything has to happen transparently to the final user, so it has to be clean & virtualisation isn't an option in this situation. Also, thanks for WinPE, it might be useful in this project for creating a deployable tweaked XP.

    Under the shower, an idea poped up... Assuming I can modify the path to the hives inside NTLDR, why would I need NTLDR to read the MAC address if I can somehow, have several copies of moded ntldr & choose the one to use at boot time, maybe using GRUB or another loader, to choose which ntldr to load.

    What do you think ?

    Thanks !
    cnc2.

  16. #16
    Join Date
    Nov 2006
    Posts
    10
    The typical way of presenting the end user with a "tweaked" image is to use sysprep.

    With sysprep you install the OS, install software, make tweaks, and so on, then you "reseal" it with sysprep. During "sealing" you can remove the license key that was there or keep it (likewise for Windows "activation"). During initial boot of a sysprepped image the end user runs through an abbreviated setup to re-enter a license key (if necessary). When the mini-setup is complete the end user has a machine with software and settings pre-installed.

    There's probably a way to do a custom one-time configuration operation during the sysprep mini-setup that the end user runs through, but I've never done it so I can't offer any advice there. I've seen vendors add their own custom setup routines which is why I'm guessing it's doable.

    Your other solution -- messing with registry hives -- is a tricky proposition. You may run afoul of code in the core OS that monitors the hives for tampering (MS added this because various products are different only by a few registry settings). There are also other issues you'll likely encounter when trying to manipulate hives directly.

  17. #17
    Join Date
    Feb 2008
    Posts
    553

    Quote Originally Posted by SuperJdynamite View Post
    The typical way of presenting the end user with a "tweaked" image is to use sysprep.

    With sysprep you install the OS, install software, make tweaks, and so on, then you "reseal" it with sysprep. During "sealing" you can remove the license key that was there or keep it (likewise for Windows "activation"). During initial boot of a sysprepped image the end user runs through an abbreviated setup to re-enter a license key (if necessary). When the mini-setup is complete the end user has a machine with software and settings pre-installed.

    There's probably a way to do a custom one-time configuration operation during the sysprep mini-setup that the end user runs through, but I've never done it so I can't offer any advice there. I've seen vendors add their own custom setup routines which is why I'm guessing it's doable.

    Your other solution -- messing with registry hives -- is a tricky proposition. You may run afoul of code in the core OS that monitors the hives for tampering (MS added this because various products are different only by a few registry settings). There are also other issues you'll likely encounter when trying to manipulate hives directly.

    Many thanks for the reply SuperJdynamite !

    SYSPREP seems to be the perfect tool for legally distributing a moded copy of Windows XP,
    it's the first time I hear about it so, thank you very much !

    My other solution is not tweaking the registry, in fact, I don't want to mod the registry itself (the structure the of the registry, the keys & values will remain the same except for some user/machine specific keys) I just want to have copies of the hives in different folders & somehow choose the one I want to use at boot time regarding the user/machine type it'll boot on. This should not interfere with the core OS monitoring because just the registry location will be changed...think about it like, the binaries are the interface & the hives are the database, if you change the location of the database you'll have to point the interface to the new location of the DB to make it work like usual.

    My main problem is in changing the path to the hives inside ntldr,then the easiest way to choose between copies will be to make copies of ntldr, like: ntldr1 loads from path1, ntldr2 loads from path2...etc & chain load ntldrX using GRUB. I'm not sure if renaming ntldr will be possible without creating big problems.

    What do you think ?

    Thanks !
    cnc2.

  18. #18
    Join Date
    Feb 2008
    Posts
    553
    I opened ntldr using IDA pro disassembler free version...& I could see the path to the hives, it seems to be easy to modify.

    Now the other problem is to find a boot loader to display a list of modified ntldr's & chainload the one I choose; I'm pretty new to GRUB so I don't know how to do it, any other solution is welcome !

    Thanks !
    cnc2.

  19. #19
    Join Date
    Feb 2008
    Posts
    553
    Hi guys !

    I've modified ntldr, I've changed the path to the hives from system32\config to system32\confi1 & renamed the the config folder as well.

    The result is a ....BSOD the ntldr is working ok but there's somthing else that can't locate the hives resulting in a crash. I know ntldr is ok because I forgot to rename the config folder & I had a message from ntldr saying can't find \confi1, after that I renamed the \config to \confi1 then booted...boot screen ok windows XP logo & loading bar then, BSOD .

    Can anyone please help me at this stage ?

    Thanks !
    cnc2.

  20. #20
    Join Date
    Nov 2006
    Posts
    10
    I forgot the original goal of what you were trying to accomplish. Can you summarize briefly what the registry hive switch is supposed to accomplish?

Page 1 of 2 12

Similar Threads

  1. Saving & Restoring Environment on Excellon router
    By dk-info in forum Uncategorised CAM Discussion
    Replies: 0
    Last Post: 08-24-2009, 11:56 AM
  2. Bobcad v22 in production environment?
    By cnczoner in forum BobCad-Cam
    Replies: 5
    Last Post: 04-18-2008, 11:23 PM
  3. What can small shops do to avoid hurting the environment?
    By InspirationTool in forum MetalWork Discussion
    Replies: 4
    Last Post: 05-07-2007, 02:25 PM
  4. Windows XP or Windows 2000 better with Mach2
    By Beezer in forum Mach Software (ArtSoft software)
    Replies: 2
    Last Post: 10-18-2004, 04:08 PM
  5. Creating a Dos Environment Via Partition Magic?
    By paulried in forum Computers / Desktops / Networking
    Replies: 21
    Last Post: 05-11-2004, 03:20 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •