Jump to content











Photo
- - - - -

Startup Programs


  • Please log in to reply
15 replies to this topic

#1 Jaydee1

Jaydee1
  • Members
  • 5 posts
  •  
    United States

Posted 15 April 2011 - 08:30 PM

How do I add a .bat file to run at startup in win7pe? I'm lost on how to do this.

#2 RoyM

RoyM

    Frequent Member

  • .script developer
  • 420 posts
  • Interests:"Booting and Owning".
  •  
    United States

Posted 15 April 2011 - 09:43 PM

*** RUNNING FROM WINPESHL.INI ANYTHING HERE LOADS VERY EARLY IN BOOT ***
TXTAddLine,%target_sys%\winpeshl.ini,"#$q%ProgramEXE% -hide -%pScrollBox5% -rebuild %delay%-registry -output#$q",APPEND


*** RUNNING FROM RUNONCE ***
Hive_Load,HKCU
//reg_add,0x1,%reg%\Microsoft\Windows\CurrentVersion\RunOnceEx\999,SetResolution,"hiderun %ProgramEXE% -hide -%pScrollBox5% -vmdetect -rebuild %delay%-registry -output"
Reg_add,0x1,%reg%\Software\Microsoft\Windows\CurrentVersion\RunOnce,SetResolution,"hiderun %ProgramEXE% -hide -rebuild -registry -output"
Hive_UnLoad,HKCU

*** RUNNING FROM START.CMD ***
If,NOT,EXISTFILE,%TargetDir%\Windows\system32\start.cmd,FileCreateBlank,%TargetDir%\Windows\system32\start.cmd
TXTAddLine,%TargetDir%\Windows\system32\start.cmd,start#$s/min#$sconfigdot3svc.cmd,PREPEND
ExtractFile,%ScriptFile%,files,configdot3svc.cmd,%TargetDir%\Windows\system32\

*** RUNNING FROM AUTORUN.CMD ***
TXTAddLine,%TargetDir%\windows\system32\autorun.cmd,"drvload.exe X:\Windows\inf\wdmaudio.inf",Append

#3 Jaydee1

Jaydee1
  • Members
  • 5 posts
  •  
    United States

Posted 18 April 2011 - 06:15 PM

So where in this would I put the file name, say if it was called File.bat??

#4 RoyM

RoyM

    Frequent Member

  • .script developer
  • 420 posts
  • Interests:"Booting and Owning".
  •  
    United States

Posted 18 April 2011 - 11:03 PM

You can write your own Scriptfile or add it to an existing.

Edit\Attachments\New folder "(Default)Name will be named Folder"
Add File.bat to Folder

*** NEXT 3 LINES JUST EXTRACT TO SYS32 AND MAKE SHORTCUT, THEY DON'T AUTOMATICALLY RUN IT ***
*** IMPORTANT TO EXTRACT TO SYS32 SO WINDOWS CAN FIND IT, ELSE FOLLOWING LINES YOU WILL ***
*** HAVE TO POINT WINDOWS TO WHERE IT ACTUALLY IS IF NOT NOT IN SYS32 ***
[process]
ExtractAllFiles,"%ScriptFile%","Folder","%Target_Sys%"
Add_Shortcut,Desktop,,"#$pSystemRoot#$p\system32\File.bat","File.bat"


*** NEXT EXAMPLES LOAD FILE.BAT ON STARTUP, JUST USE ONE OF THEM AS APPROPRIATE ***
*** DEPENDING ON WHAT FILE.BAT DOES, YOU MAY WANT TO VARY WHEN IT LOADS AT BOOT TIME ***
*** (I.E) DRIVERS YOU MAY WANT TO LOAD EARLY, OTHER TASKS MAYBE NOT SO EARLY ***

*** RUNNING FROM WINPESHL.INI ANYTHING HERE LOADS VERY EARLY IN BOOT ***
TXTAddLine,%target_sys%\winpeshl.ini,"File.bat",APPEND


*** RUNNING FROM RUNONCE ***
Hive_Load,HKCU
Reg_add,0x1,%reg%\Software\Microsoft\Windows\CurrentVersion\RunOnce,File.bat,"hiderun File.bat"
Hive_UnLoad,HKCU

*** RUNNING FROM START.CMD ***
If,NOT,EXISTFILE,%TargetDir%\Windows\system32\start.cmd,FileCreateBlank,%TargetDir%\Windows\system32\start.cmd
TXTAddLine,%TargetDir%\Windows\system32\start.cmd,start#$s/min#$sFile.bat,PREPEND

*** RUNNING FROM AUTORUN.CMD ***
TXTAddLine,%TargetDir%\windows\system32\autorun.cmd,"File.bat",Append

Add_Shortcut,AutoRun,,"#$pSystemRoot#$p\system32\File.bat","File.bat"

#5 Jaydee1

Jaydee1
  • Members
  • 5 posts
  •  
    United States

Posted 21 April 2011 - 06:12 PM

Thanks! Lots of help. =)

#6 jgarizona

jgarizona
  • Members
  • 2 posts
  •  
    United States

Posted 09 September 2011 - 11:04 PM

Let me start by saying that i am new to this. Using the most wonderful WIN7PE_SE project. I am trying to execute a file at boot up. This app requires user input.


The location of the file will be x:\menu The file name is menu.exe

I edited the 9-autorun.script located in the build folder.
After the [interface] section, based on the instructions above; running it from start.cmd i think that the correct syntex is:

If,NOT,EXISTFILE,%TargetDir%\Windows\system32\start.cmd,FileCreateBlank,%TargetDir%\Windows\system32\start.cmd
TXTAddLine,%TargetDir%\Windows\system32\start.cmd,start#$s/min#$sx:\menu\menu.exe,PREPEND
ExtractFile,%ScriptFile%,files,x:\menu\menu.exe,%TargetDir%\Windows\system32\



That didnt seem to work so i removed those commands

I tried to add adding the following command to the same script:

TXTAddLine,"%TargetDir%\windows\system32\autorun.cmd","x:\menu\menu.exe","Append"

After the "echo off","Append" line in the [interface] section.

None of those seem to work. I dont see any errors messages. What am I doing wrong?

Thanks in advance.

#7 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 10 September 2011 - 11:58 AM

The location of the file will be x:\menu The file name is menu.exe

After the [interface] section, based on the instructions above; running it from start.cmd i think that the correct syntex is:

If,NOT,EXISTFILE,%TargetDir%\Windows\system32\start.cmd,FileCreateBlank,%TargetDir%\Windows\system32\start.cmd
TXTAddLine,%TargetDir%\Windows\system32\start.cmd,start#$s/min#$sx:\menu\menu.exe,PREPEND
ExtractFile,%ScriptFile%,files,x:\menu\menu.exe,%TargetDir%\Windows\system32\

You have a problem with your path x:\menu\menu.exe and extract in %TargetDir%\Windows\system32\
You can not have x:\Menu, X is the drive where boot.wim is mounted


to have it in Y:\menu\menu.exe
If,Not,EXISTDIR,%TargetDir%\Menu,DirMake,%TargetDir%\Menu
ExtractFile,%ScriptFile%,files,menu.exe,%TargetDir%\Menu

to have menu.exe in X:\windows\sytem32
ExtractFile,%ScriptFile%,files,menu.exe,%target_sys%

Look at the examples of RoyM, forget maybe start.cmd and winpeshl.ini at first step

Before shell (explorer, ...)
AddAutoRun

After shell
autorun.cmd
or
RunOnce

:cheers:

#8 ChrisBA

ChrisBA
  • Members
  • 8 posts
  •  
    Germany

Posted 24 October 2011 - 08:11 AM

Hi, everybody!

I am new to this, too, and I'm trying to build a WIN7PE image where I want to autorun a customized portable Firefox in kiosk-mode (using the firefox extension r-kiosk) and automatically loading a certain webpage AFTER the "PENetwork" script finished. Unfortunately, Firefox always opens up while PENetwork is still running, thus not being able to load the webpage lacking a network connection. Here is what I do within the Firefox-script (based upon the very useful hints in this thread as well as the winbuilder documentation):


...

ExtractAllFiles,"%ScriptFile%","FolderFF","%Target_Sys%"

AddPostConfig,"FirefoxPortable.bat",x:windowssystem32FirefoxPortable.bat,,2


In the batch-script I am trying to achieve a delay by running


@ping -n 60 localhost> nul


prior to calling the firefox executable, but this doesn't seem to work either (probably also due to the lacking network connection at that time).

Long story short, how would I achieve that Firefox open up after the network connection has been established?

Thx a lot in advance!

Kind regards,
Chris

#9 pscEx

pscEx

    Platinum Member

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

Posted 24 October 2011 - 08:55 AM

Hi ChrisBA!

Welcome in our community!

PENetwork offers the feature to start one or more processes after the network is up.

In the PENetwork GUI, click "Start Editor" and define your firefox in the "CMDs after startup" tab.

Peter

#10 ChrisBA

ChrisBA
  • Members
  • 8 posts
  •  
    Germany

Posted 24 October 2011 - 08:58 AM

Hi, Peter!

Awesome - it can be so easy sometimes (thx to the great work of everyone involved, of course).

Danke Dir! :-)

Regards,
Chris

#11 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 24 October 2011 - 09:26 AM

PENetwork offers the feature to start one or more processes after the network is up.

In the PENetwork GUI, click "Start Editor" and define your firefox in the "CMDs after startup" tab.

That on the next Holger's Penetwork version ;).
On the current version, there is a problem with "CMDs after startup"

*
You idea to wait 60 seconds is good try with ping 127.0.0.1 -n 60
or with a small autoit program and wait 1mn (loop) until process PENetwork finish

:cheers:

#12 pscEx

pscEx

    Platinum Member

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

Posted 24 October 2011 - 10:08 AM

That on the next Holger's Penetwork version ;).
On the current version, there is a problem with "CMDs after startup"

Nice to see that not only in my scripts the user should not believe everything he sees! ;)

BTW: There are never problems, there are only issues! :smart:

Peter :cheers:

#13 MedEvil

MedEvil

    Platinum Member

  • .script developer
  • 7771 posts

Posted 24 October 2011 - 11:54 AM

How about running PENetwork and Firefox from a batchfile?

This way, firefox would not be started until PENetwork finishes, but also no pointless waiting for a timeout.

:cheers:
  • pscEx likes this

#14 ChrisBA

ChrisBA
  • Members
  • 8 posts
  •  
    Germany

Posted 24 October 2011 - 12:30 PM

@MedEvil: Very nice and not unnecessarily complicated - works like a charm!

@all: nonetheless thx very much for your fast responses as well!

#15 RoyM

RoyM

    Frequent Member

  • .script developer
  • 420 posts
  • Interests:"Booting and Owning".
  •  
    United States

Posted 24 October 2011 - 05:46 PM

FYI, There also exists timeout.exe, in my batches, 5 seconds seems to be just right
for PeNetwork to finish completely, "Your Mileage May Vary", Depending upon your network setup.

Another new command in Vista/7 is "timeout".
Use the "timeout" command to make a Vista/7 batch file wait.
It will cause the command processor to wait for a specified number of seconds or until a key is pressed.

The format is: timeout /T n
where n is the number of seconds to wait.
To make the command ignore any key presses, the switch /nobreak can be added:
timeout /T n /nobreak
Because the command gives output listing the time remaining,
it may be necessary to use a redirect to nul.
timeout /T n > nul

Example: StartFirefoxPortable.cmd
start /wait penetwork.exe
timeout 5
call FirefoxPortable.bat

Somewhat insignifigant, FirefoxPortable should be .cmd
"However, if it works, Don't Fix it".

#16 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 25 October 2011 - 11:33 AM

Good :), all that are workarounds.

I see that many of us wait for the next version of Holger's Penetwork, which would correct the "CMDs after startup" option and many other things :thumbsup:. Notice to all futures testers ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users