Topic: Permanent Variable On Bootup  (Read 2417 times)

Permanent Variable On Bootup
« on: November 04, 2012, 03:44:05 PM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 268
Is there a way to setup a permanent variable for that session of the PE like %systemroot% example

if I run this

Code: [Select]
set TagFile=\laddsbootUSB.tag

For %%I in (C D E F G H I J K L M N O P Q R S T U V W X Y Z A B) do (dir %%I:\ 1>nul 2>nul && if /i exist %%I:%TagFile% set LaddsUSB=%%I:)

%LaddsUSB%\

How do I make the LaddsUSB variable permanent for that PE session like systemroot? I dont want to have to define this in every script after my main variable setup script has run at bootup

Code: [Select]
For %%I in (C D E F G H I J K L M N O P Q R S T U V W X Y Z A B) do (dir %%I:\ 1>nul 2>nul && if /i exist %%I:%TagFile% set LaddsUSB=%%I:)   

Of course I realize once I restart the PE, I would lose the variable but thats why I have my autorun command to reset it or would it be easier just to use SETLOCAL to pass the variable to the next script?
« Last Edit: November 04, 2012, 03:46:31 PM by laddanator »

Re: Permanent Variable On Bootup
« Reply #1 on: November 04, 2012, 04:14:14 PM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 10350
Is there a way to setup a permanent variable for that session of the PE
Yes
like %systemroot% example
Well not a good example .....  :wink:, %temp% is a better example  :thumbsup:

I guess adding 3 more lines to your batch will do the task
(2nd line to assure in case....)

Code: [Select]
reg.exe add "HKCU\Environment" /v LaddsUSB /t REG_SZ /f /d "%LaddsUSB%"
Set LaddsUSB=%LaddsUSB%
BroadcastEnvChange.exe


and enable Win7PESE\Tweaks\"ImDisk Ramdisk" on your test

Let us know how it goes....


ps: btw, you can make small builds for faster virtual tests by deselecting most default things.... ;)




I dont want to have to define this in every script after my main variable setup script has run at bootup
Well well,
you do not need above "with scripts", neither Win7PESE nor Gena ,
both projects have "Run From CD" option, available on scripts,
So all you need to do is, selecting this option on scripts.....  :whistling:

There are also some more options/methods for scripts (aiming same tasks, different / flexible methods ;)) .....
as far as you well define what you are trying to achive .......


what you are after (adding a Hot Environmental variable) is more valuable than scripts,
 but for your own customized portabilation on disk (ufd, usb etc..)..
Which I may guess, after / IF you well organise, we can put to projects too  :thumbsup:

:ymca:

Re: Permanent Variable On Bootup
« Reply #2 on: November 04, 2012, 04:34:05 PM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 268
Will BroadcastEnvChange.exe change my temp directory? I need temp to stay B: so this may be more what I need?

Code: [Select]
reg.exe add "HKCU\Environment" /v LaddsUSB /t REG_SZ /f /d "%LaddsUSB%"

Re: Permanent Variable On Bootup
« Reply #3 on: November 04, 2012, 05:10:17 PM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 268
This worked perfectly

Code: [Select]
set TagFile=\laddsbootUSB.tag

For %%I in (C D E F G H I J K L M N O P Q R S T U V W X Y Z A B) do (dir %%I:\ 1>nul 2>nul && if /i exist %%I:%TagFile% set LaddsUSB=%%I:)

reg.exe add "HKCU\Environment" /v LaddsUSB /t REG_SZ /f /d "%LaddsUSB%"

Helpful as usually! Thanks  :celebrate: :celebrate:


I just realized how conceded I must seem, using my name and all in my bootstuff!  :rolf:

 

Powered by EzPortal