Jump to content











Photo
- - - - -

RegAddBoot script updates


  • Please log in to reply
93 replies to this topic

#76 dera

dera

    Gold Member

  • .script developer
  • 1335 posts
  •  
    Hungary

Posted 29 November 2009 - 03:52 PM

if the '/m ' switch used then it writes to HKLM\SYSTEM\CurrentControlSet

So without a running Explorer it's useless

exactly that is the case

#77 dera

dera

    Gold Member

  • .script developer
  • 1335 posts
  •  
    Hungary

Posted 29 November 2009 - 04:44 PM

@JonF
did you try to modify the value 'CmdLine' in the key 'HKLM\SYSTEM\Setup' in the VistaPE registry
not point to the 'winpeshl.exe'
but point to your complied AutoIT pre-loader which try to set the 'cddrive' first,
then call the winpeshl.exe after this 'cddrive' was written to the registry key 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'?

#78 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 29 November 2009 - 05:17 PM

... AutoIT pre-loader which try to set the 'cddrive' first,
then call the winpeshl.exe after this 'cddrive' was written to the registry key 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'?

On my XP host this runs well:
  • Add a new variable to '...\Session Manager\Environment'
  • Run BroadcastEnvChange /broadcast
  • Open a cmd window
  • See the new variable in 'Set'
That is equivalent to what dera suggested.

Peter

#79 JonF

JonF

    Gold Member

  • .script developer
  • 1185 posts
  • Location:Boston, MA
  •  
    United States

Posted 30 November 2009 - 01:23 AM

The 99%+ solution is simple. Use AutoIT's envset to modify the current process's environment, then runwait vpeldr.exe leaving preloader active in memory. Vpeldr and all its child processes, including the shell, inherit the modified environment. Now I want to test to see if a message to specific windows will work where a broadcast doesn't, to update the environment of winlogon and whatnot.

#80 JonF

JonF

    Gold Member

  • .script developer
  • 1185 posts
  • Location:Boston, MA
  •  
    United States

Posted 01 December 2009 - 01:37 PM

OK. The update is now on the VistaPE-CAPI server. I decided to useh a method that Dera PM'd me, since it uses a little less RAM than my method. (Thanks, Dera). One way or another, VistaPE-CAPI now hhas a CDDrive environment variable.

Now what?

#81 Lancelot

Lancelot

    Frequent Member

  • .script developer
  • 5013 posts
  • Location:Turkiye/Izmir
  • Interests:*Mechanical stuff and Physics,
    *LiveXP, BartPE, SherpyaXPE,
    *Basketball and Looong Walking,
    *Buying outwear for my girlf (Reason: Girls are stupid about buying bad stuff to make themselves uglier :))
    *Girls (Lyric: Girl,...., You will be a womann, Soon)
    *Answering questions for "Meaning of life",
    *Helping people,

    Kung with LiveXP, Fu with Peter :)
  •  
    Turkey

Posted 01 December 2009 - 01:59 PM

JonF
and Dera

yipppiyeeeyaaayooooooo ;)
:clap: :clap: ;)

Now what?


I guess time to change capi for vistape ?

btw reminding:

LiveXP (bootsdi builds giving example with filezilla script by using enu source):
runfromram enabled ==> filezilla is in .img file at X:\Program Files RAM\Filezilla
runfromcd enabled ===> filezilla is on cd at ??:\Program Files CD\Filezilla (??=%PEdrive% at env variables)
rundefault enabled ===> filezilla is in .img file at X:\Program Files\Filezilla


a similar mechanism at capi can be made on vistapecapi ??
what you think ?


Edit 2010-03-28:

I decide to add paraglider's useful info here for future reference after this topic

Just making the registry value REG_EXPAND_SZ does not automatically ensure the environment variables get expanded when read. RegQueryValueEx does not expand them. Its still up to the caller to call ExpandEnvironmentStrings on the returned value to expand it.

However if the registry is read with RegGetValue ( only supported on Vista or later ) then by default the environment variables are expanded - this can be suppressed with the RRF_NOEXPAND option.

SHRegGetValue does expand environment variables unless SRRF_NOEXPAND is specified.



#82 Galapo

Galapo

    Platinum Member

  • .script developer
  • 3841 posts
  •  
    Australia

Posted 01 December 2009 - 11:24 PM

I decided to useh a method that Dera PM'd me, since it uses a little less RAM than my method. (Thanks, Dera).

Can you fill us in on what that method is so we have the method documented for reference?

Thanks,
Galapo.

#83 JonF

JonF

    Gold Member

  • .script developer
  • 1185 posts
  • Location:Boston, MA
  •  
    United States

Posted 02 December 2009 - 12:39 AM

Can you fill us in on what that method is so we have the method documented for reference?

Well, my way was to point to a compiled AutoIT program in winpeshl.ini. This program added CDDrive to its local environment and ran vpeldr.exe which in turn ran the appropriate shell, each getting a copy of the environment containing CDDrive. Of course the compiled AutoIT program remained resident, using about 5 MB. (If I killed the compiled AutoIT process, the system soon rebooted).

Dera's way was to point to a .cmd file in CmdLine in HKLM\Setup. This file ran a compiled AutoIT program which put CDDrive in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and ran the envupdate function (which cmd.exe {which was activated to run the .cmd file} listened to and updated its environment). The AutoIT program exited and next the .cmd file ran winpeshl.exe which ran vpeldr.exe (specified in winpeshl.ini) which started the shell, each receiving a copy of cmd.exe's environment containing CDDrive. Of course this left a portion of cmd.exe resident, using about 1.5 MB.

#84 Galapo

Galapo

    Platinum Member

  • .script developer
  • 3841 posts
  •  
    Australia

Posted 02 December 2009 - 12:52 AM

Hi JonF,

Thanks, I understand now how you got it to work.

You could still use just your AutoIt program and use this memory reduction function. Should take the usage down to about 0.7mb. Call it your loop.

While 1

	Sleep(500)

	_ReduceMemory()

Wend



Func _ReduceMemory()

	Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId')

	Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ai_GetCurrentProcessId[0])

	Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])

	DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])

	Return $ai_Return[0]

EndFunc

Regards,
Galapo.

#85 Arvy

Arvy

    Frequent Member

  • Developer
  • 430 posts
  • Location:Canada, Parry Sound
  • Interests:IT, Outdoors, Horses
  •  
    Canada

Posted 02 December 2009 - 08:14 AM

This file ran a compiled AutoIT program which put CDDrive in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and ran the envupdate function ...

Interesting. I'm very curious about that part of your process. Perhaps you'd be willing to show us your PreLoader.au3 script file. Whatever method Nightman was using to establish his %CDDrive% envvar for VistaPE's RegAddBoot process, it seems quite transient and not available at that point in any case. I found that I had to do something like this:
#NoTrayIcon

$cddrv = EnvGet("CDDrive")

$drives = DriveGetDrive("ALL")

If NOT @error AND NOT $cddrv Then

	For $i = 1 to $drives[0]

		$flagfile = $drives[$i] & "\vistape.cfg"

		If DriveStatus&#40;$drives&#91;$i&#93;&#41; <> &#34;UNKNOWN&#34; AND DriveStatus&#40;$drives&#91;$i&#93;&#41; <> &#34;NOTREADY&#34; Then

			If FileExists&#40;$flagfile&#41; Then

				$cddrv = StringUpper&#40;$drives&#91;$i&#93;&#41;

				ExitLoop

			EndIf

		EndIf

	Next

EndIf

RegWrite

&#40;&#34;HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment&#34;, &#34;CDDrive&#34;, &#34;REG_SZ&#34;, $cddrv&#41;

EnvUpdate&#40;&#41;


#86 dera

dera

    Gold Member

  • .script developer
  • 1335 posts
  •  
    Hungary

Posted 02 December 2009 - 08:39 AM

exactly which script in the VistaPE project was updated?

(anyway i used this au3, only corrected 'REG_EXPAND_SZ' into 'REG_SZ'
and that was my experience:
if the complied au3 ran before the winpeshl.exe via "HKLM\Setup","CmdLine","mycommand.cmd" then the EnvUpdate() not needed at all
and it works also in BS Explorer building only from the WAIK,

if "HKLM\Setup","CmdLine", "winpeshl.exe" used and the complied au3 ran before the vpeldr.exe via the winpeshl.ini [LaunchApps] section
then EnvUpdate() doesn't help)

#87 Arvy

Arvy

    Frequent Member

  • Developer
  • 430 posts
  • Location:Canada, Parry Sound
  • Interests:IT, Outdoors, Horses
  •  
    Canada

Posted 02 December 2009 - 08:53 AM

@dera: If you're asking me, our findings appear to be similar with respect to the start-up sequence and EnvUpdate() results. The reason my AutoIt script checks ALL drives for the flag file (not just CDROMs as in your script) is because I sometimes boot VistaPE and its programs located on a USB drive.

#88 dera

dera

    Gold Member

  • .script developer
  • 1335 posts
  •  
    Hungary

Posted 02 December 2009 - 08:59 AM

that is not my au3
(i am not able to write code)
and for me Pedrole15's au3 can find the tag file also on the UFD

#89 Arvy

Arvy

    Frequent Member

  • Developer
  • 430 posts
  • Location:Canada, Parry Sound
  • Interests:IT, Outdoors, Horses
  •  
    Canada

Posted 02 December 2009 - 09:05 AM

Sorry. I meant the script that your link (above) pointed to. Anyhow, I'll be very interested in seeing JonF's final solution if he's willing to post his Preloader.au3.

#90 dera

dera

    Gold Member

  • .script developer
  • 1335 posts
  •  
    Hungary

Posted 02 December 2009 - 09:11 AM

$CDRoms lines are commented out in that au3
i mean the text in the code box in Pedrole15's original post,
not Max's attachment

#91 Arvy

Arvy

    Frequent Member

  • Developer
  • 430 posts
  • Location:Canada, Parry Sound
  • Interests:IT, Outdoors, Horses
  •  
    Canada

Posted 02 December 2009 - 09:38 AM

Yes, okay. Thanks dera.

In any case, what I was really curious about were JonF's final methodological approach for determining the drive letter variable to be entered into the registry and his placement of that part of his process into the overall VistaPE start-up sequence.

As you point out, the latter factor appears critical to the ultimate impact (if any at all) of the EnvUpdate() function. I'm puzzled about why it should be necessary to keep it in memory if the session manager is actually able to establish it subsequently as it does with all the other entries that are held under the same environment key in the registry.

#92 JonF

JonF

    Gold Member

  • .script developer
  • 1185 posts
  • Location:Boston, MA
  •  
    United States

Posted 02 December 2009 - 01:51 PM

exactly which script in the VistaPE project was updated?

(anyway i used this au3, only corrected 'REG_EXPAND_SZ' into 'REG_SZ'
and that was my experience:
if the complied au3 ran before the winpeshl.exe via "HKLM\Setup","CmdLine","mycommand.cmd" then the EnvUpdate() not needed at all
and it works also in BS Explorer building only from the WAIK,

if "HKLM\Setup","CmdLine", "winpeshl.exe" used and the complied au3 ran before the vpeldr.exe via the winpeshl.ini [LaunchApps] section
then EnvUpdate() doesn't help)

AFAIK NightMan never created a CDDrive environment variable. He replaced %CDDrive% with the appropriate drive letter as he created the shortcuts, on the fly. But he forgot to do that for the arguments portion of the shortcut specification.

My code is contained inb the script, but here it is:

$CfgFile = &#34;vistape.cfg&#34;

$CDLetter = False

$Letter = DriveGetDrive&#40;&#34;all&#34;&#41;

For $L = 1 To $Letter&#91;0&#93;

  If &#40;StringRegExp&#40;$Letter&#91;$L&#93;, &#34;&#40;?i&#41;^&#40;A|B&#41;&#58;$&#34;&#41;&#41; Then ContinueLoop

  If &#40;StringRegExp&#40;DriveStatus&#40;$Letter&#91;$L&#93;&#41;, &#34;READY&#34;&#41; <> 0&#41; Then

	If FileExists&#40;$Letter&#91;$L&#93; & &#34;\&#34; & $CfgFile&#41; Then

	  $CDLetter = StringUpper&#40;$Letter&#91;$L&#93;&#41;

	  ExitLoop

	EndIf

  EndIf

Next



If $CDLetter Then

  RegWrite&#40;&#34;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment&#34;,&#34;CDDrive&#34;,&#34;REG_SZ&#34;,$CDLetter&#41;

 &#59; Not many apps listen to this broadcast, but cmd.exe does. So this program

 &#59; should be run in a .cmd file so cmd.exe will listen and maintain the environment

 &#59; variable after this program exits.

  EnvUpdate&#40;&#41;

EndIf


#93 JonF

JonF

    Gold Member

  • .script developer
  • 1185 posts
  • Location:Boston, MA
  •  
    United States

Posted 02 December 2009 - 01:52 PM

exactly which script in the VistaPE project was updated?

07-config.script. I may have messed up the update; try downloading now.

#94 dera

dera

    Gold Member

  • .script developer
  • 1335 posts
  •  
    Hungary

Posted 02 December 2009 - 04:20 PM

Thanks!
ok, now i can see the updated scripts




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users