Topic: [help] how to get runonce to work?  (Read 5463 times)

[help] how to get runonce to work?
« on: June 13, 2013, 07:01:15 PM »

biatche

  • Jr. Chef
  • **
  • Date Registered: Jun 2013
  • Posts: 57
Code: [Select]
RegHiveLoad,Tmp_Software,%RegSoftware%
RegWrite,HKLM,0x1,"Tmp_Software\Microsoft\Windows\CurrentVersion\RunOnce","PEstartCustom","#$q%SystemDrive%\Windows\System32\PEstart-custom.cmd#$q"
RegHiveUnLoad,Tmp_Software

What's wrong with this? Within PE, copy pasting the quoted value from regedit definitely works. So yes, the registry exists, the path exists, but it doesn't run upon startup.

Re: [help] how to get runonce to work?
« Reply #1 on: June 13, 2013, 09:35:13 PM »

ChrisR

  • XPE Baker
  • Grand Chef
  • *****
  • Date Registered: Mar 2011
  • Posts: 3494
Try with Reg_Expand_Sz (0x2) and Default Hive (HKCU)
Code: [Select]
RegHiveLoad,Tmp_Default,%RegDefault%
RegWrite,HKLM,0x2,Tmp_Default\Software\Microsoft\Windows\CurrentVersion\RunOnce,PEstartCustom,#$q%SystemDrive%\Windows\System32\PEstart-custom.cmd#$q
RegHiveUnLoad,Tmp_Default

Re: [help] how to get runonce to work?
« Reply #2 on: June 14, 2013, 10:14:56 AM »

biatche

  • Jr. Chef
  • **
  • Date Registered: Jun 2013
  • Posts: 57
Try with Reg_Expand_Sz (0x2) and Default Hive (HKCU)
Code: [Select]
RegHiveLoad,Tmp_Default,%RegDefault%
RegWrite,HKLM,0x2,Tmp_Default\Software\Microsoft\Windows\CurrentVersion\RunOnce,PEstartCustom,#$q%SystemDrive%\Windows\System32\PEstart-custom.cmd#$q
RegHiveUnLoad,Tmp_Default

With your code, it doesn't add to registry at all.
It doesn't work with 0x1, quotes,

I've tried various combinations actually already before posting. None work.

In my very old Win7PE_SE, this was the last one that worked:

Code: [Select]
Hive_Load,HKCU
Reg_add,0x1,%reg%\Software\Microsoft\Windows\CurrentVersion\RunOnce,Startup,"\\bbx\iw7pe$\_netcmd\startup.cmd"
Hive_UnLoad,HKCU

This definitely works. It still utilize Reg_add, which is no longer existent in the new version, right?

Re: [help] how to get runonce to work?
« Reply #3 on: June 14, 2013, 10:53:53 AM »

ChrisR

  • XPE Baker
  • Grand Chef
  • *****
  • Date Registered: Mar 2011
  • Posts: 3494
With your code, it doesn't add to registry at all.
Sorry but it should work :wink:
It is made like that in Autorun, Pstart, ex: PeNetwork below
Code: [Select]
RegHiveLoad,Tmp_Default,%RegDefault%
RegWrite,HKLM,0x2,Tmp_Default\Software\Microsoft\Windows\CurrentVersion\RunOnce,PENetwork,"#$q%PE_Programs%\%ProgramFolder%\%ProgramEXE%#$q"
RegHiveUnLoad,Tmp_Default

And I just tried it in Code Box without worries, it works
Quote
File [%BaseDir%\Projects\Win8PESE\CodeBox.txt] Version [1]
 
  AddVariables - Added section [ApiVar] from file [%BaseDir%\Projects\Win8PESE\Build\Macro_Library.script] into the local variable list
  RegHiveLoad - File: [%BaseDir%\Target\Win8PESE\Windows\System32\config\Default] Section [Tmp_Default]
  RegWrite - Type: [0x2] Section [HKLM\Tmp_Default\Software\Microsoft\Windows\CurrentVersion\RunOnce] Key [PEstartCustom]: "%SystemDrive%\Windows\System32\PEstart-custom.cmd"
  RegHiveUnLoad - Unloaded registry hive: [Tmp_Default]

  Finished processing script: CodeBox test
 
  Script time: 222 milliseconds

  Script has been sucessfully processed!
Checked with Utils\Regedit, I have well the key in HKLM\Tmp_Default\Software\Microsoft\Windows\CurrentVersion\RunOnce

ps: the old syntax does the same things

Re: [help] how to get runonce to work?
« Reply #4 on: June 14, 2013, 11:03:58 AM »

biatche

  • Jr. Chef
  • **
  • Date Registered: Jun 2013
  • Posts: 57
Code: [Select]
[main]
Title=PersCustom
Type=script
Author=biatche
Description=Personal Customizations
Selected=True
Level=8
Version=002

[Variables]

[Process]
Require_File,"choice.exe",%Source_Sys%,%Target_Sys%
Require_File,"choice.exe.mui","%Source_Sys%\%DistLang%","%Target_Sys%\%DistLang%"
Require_File,"findstr.exe",%Source_Sys%,%Target_Sys%
Require_File,"findstr.exe.mui","%Source_Sys%\%DistLang%","%Target_Sys%\%DistLang%"
Require_File,"getmac.exe",%Source_Sys%,%Target_Sys%
Require_File,"getmac.exe.mui","%Source_Sys%\%DistLang%","%Target_Sys%\%DistLang%"
Require_File,"timeout.exe",%Source_Sys%,%Target_Sys%
Require_File,"timeout.exe.mui","%Source_Sys%\%DistLang%","%Target_Sys%\%DistLang%"
Require_File,"w32tm.exe",%Source_Sys%,%Target_Sys%
Require_File,"w32tm.exe.mui","%Source_Sys%\%DistLang%","%Target_Sys%\%DistLang%"


RegHiveLoad,Tmp_Default,%RegDefault%
RegWrite,HKLM,0x2,Tmp_Default\Software\Microsoft\Windows\CurrentVersion\RunOnce,PEstartCustom,#$q%SystemDrive%\Windows\System32\PEstart-custom.cmd#$q
RegHiveUnLoad,Tmp_Default

//RegHiveLoad,Tmp_Software,%RegSoftware%
//RegWrite,HKLM,0x1,"Tmp_Software\Microsoft\Windows\CurrentVersion\RunOnce","PEstartCustom","#$q%SystemDrive%\Windows\System32\PEstart-custom.cmd#$q"
//RegHiveUnLoad,Tmp_Software


This is the entire script, while the cmd is in winbuilderdir\Custom\Win8PESE\Windows\System32\PEstart-custom.cmd

Do you see any mistakes? It definitely doesn't display in regedit in the running winpe. Mind testing it? Thanks :)

Re: [help] how to get runonce to work?
« Reply #5 on: June 14, 2013, 01:08:48 PM »

ChrisR

  • XPE Baker
  • Grand Chef
  • *****
  • Date Registered: Mar 2011
  • Posts: 3494
For better writting, simplier and faster, use Require_FileQ
Code: [Select]
[Process]
Require_FileQ,choice.exe
Require_FileQ,findstr.exe
Require_FileQ,getmac.exe
Require_FileQ,timeout.exe
Require_FileQ,w32tm.exe

RegHiveLoad,Tmp_Default,%RegDefault%
RegWrite,HKLM,0x2,Tmp_Default\Software\Microsoft\Windows\CurrentVersion\RunOnce,PEstartCustom,#$q%SystemDrive%\Windows\System32\PEstart-custom.cmd#$q
RegHiveUnLoad,Tmp_Default

Otherwise no worries it should work,
if it is not the case, in PE check HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce and PEstart-custom.cmd in x:\windows\system32
also, Add an echo blabla > X:\Windows\Temp\PEstart-custom.log at the beggining and a pause at the end.

You have to play now, I do not have enough time to help more here.

Re: [help] how to get runonce to work?
« Reply #6 on: June 14, 2013, 01:11:51 PM »

biatche

  • Jr. Chef
  • **
  • Date Registered: Jun 2013
  • Posts: 57
I've been playing a lot.... and when after ip change commands run, runonce runs as well.. so there SEEMS to be a combination of things that can cause this....

all i require is for a .cmd script to run at runonce, with that i can mount the network drive via cmd...

Re: [help] how to get runonce to work?
« Reply #7 on: June 14, 2013, 02:10:01 PM »

ChrisR

  • XPE Baker
  • Grand Chef
  • *****
  • Date Registered: Mar 2011
  • Posts: 3494
I have well understood and I have done the same test as you, here and also for PeNetwork_After.cmd.
Here all this works well, I really do not understand what is the problem.

I've been playing a lot.... and when after ip change commands run, runonce runs as well.. so there SEEMS to be a combination of things that can cause this....
Maybe you have an other script which interferes, I don't know but RunOnce works well normally without the need for network or change IP.
Retry perhaps with the oriiginal package, nothing else, just RunOnce and PeNetwork_After


Re: [help] how to get runonce to work?
« Reply #8 on: June 14, 2013, 02:15:19 PM »

biatche

  • Jr. Chef
  • **
  • Date Registered: Jun 2013
  • Posts: 57
I've removed the runonce scripts, combined my cmd scripts, and have penetwork run After shell.
Here it doesn't execute the after ip change commands (tested with normal, wait, nowait)..... and disabled penetwork_after.cmd since it never executes anyway...

This randomness is really making me go nuts.



afterip.cmd
Code: [Select]
@echo off
echo Waiting for network to start... (up to 20 tries)
for /l %%a in (1,1,20) do (
if exist z:\ (
goto :networkok
) else (
net use z: \\bbx\iw7pe$ /user:Guest "" >nul
if %errorlevel% equ 0 ( goto :networkok ) else ( echo Attempt %%a fail.. )
timeout /t 1 >nul
)
)

:networkok
if exist "z:\_netcmd\startup.cmd" call z:\_netcmd\startup.cmd

Nothing wrong here right? Well manually executing it does work, so the problem is that it's not being executed.

Re: [help] how to get runonce to work?
« Reply #9 on: June 14, 2013, 04:19:47 PM »

ChrisR

  • XPE Baker
  • Grand Chef
  • *****
  • Date Registered: Mar 2011
  • Posts: 3494
Not to go crazy, really, do your test with a clean Win8pese with the default config and nothing else starting from the latest package. You will do other things after.
RunOnce, PEnetwork Cmd after startup, Cmd after changing IP setting works without worry here. After changing the IP setting, use apply.


On this fresh win8pese, Add PeNetwork_After.cmd, PeNetwork_AfterIP.cmd, PEstart-custom.cmd
Use Penetwork "Include file in system32" Explorer button to add them. Default folder %GlobalTemplates%\PENetwork_Include (or .\Workbench\Common\PENetwork_Include)

With just that inside for each (change the name, of course)
Code: [Select]
echo PeNetwork_After %time%
echo PeNetwork_After %time% >X:\Windows\Temp\PeNetwork_After.log
pause

and in your own PENetwork.ini, in folder Workbench\Common\PENetwork\Win8PESE\ini, add
Code: [Select]
CMDStart.CMD1=PeNetwork_After.cmd
CMDStart.Start1=Normal
CMDStart.Wait1=Yes
CMDChange.CMD1=PeNetwork_AfterIP.cmd
CMDChange.Start1=Normal
CMDChange.Wait1=Yes

And finally add this small test script in Apps folder:

Code: [Select]
[main]
Title=PEstart-custom test
Type=script
Author=biatche
Description=PEstart-custom test RunOnce
Selected=True
Level=5
Version=001

[Process]
RegHiveLoad,Tmp_Default,%RegDefault%
RegWrite,HKLM,0x2,Tmp_Default\Software\Microsoft\Windows\CurrentVersion\RunOnce,PEstartCustom,PEstart-custom.cmd
RegHiveUnLoad,Tmp_Default

It should works

Re: [help] how to get runonce to work?
« Reply #10 on: June 14, 2013, 05:22:04 PM »

biatche

  • Jr. Chef
  • **
  • Date Registered: Jun 2013
  • Posts: 57
OK things are working fine now..

My workaround was...

to run penetwork after shell, execute a batchfile after startup ...

there was an issue with the batch file

net use z: \\bbx\iw7pe$ /user:Guest "" >nul
if %errorlevel% equ 0 ( goto :networkok ) else ( echo Attempt %%a fail.. )

You may think that the errorlevels work out, but if DHCP ip has been leased, the client ip may still need time for the ip to be operational. It SHOULD return an errorlevel if it is unable to connect due to "no hardware connectivity", but no, errorlevel is 0 also.
It is only when the network path is incorrect, or username is incorrect which is when you get an errorlevel.

Autorun might have worked too.... just that the i7-4770 does it so fast there was no window perhaps.

Thank you for all the help!

 

Powered by EzPortal