Topic: What is %target_sys%? (another newbe question)  (Read 9816 times)

What is %target_sys%? (another newbe question)
« on: April 28, 2015, 03:01:11 PM »

dcc

  • Jr. Chef
  • **
  • Date Registered: Apr 2015
  • Posts: 13
I changed a bunch of the default values of the project, and suddenly it builds for me.   Hooray!  Now to start customizing.

It appears if I put a file called "autorun.cmd" in the  %target_sys% subdirectory, it will get run at startup.

GREAT!!

But....  what is this subdirectory? (where do I find it or make it or establish it)??

I did search and not find this question.  Apologies if it does exist somewhere

Re: What is %target_sys%? (another newbe question)
« Reply #1 on: April 28, 2015, 04:32:48 PM »

anshad

  • Chef
  • ***
  • Date Registered: Apr 2012
  • Posts: 323
Hi

You don't need to create "Autorun.cmd" manually. By default Build-->Autorun script will create an empty "Autorun.cmd" file. The executable "Autorun.exe" will execute this batch file and any command written on it. An example is given on the script interface to illustrate how to add custom commands to this batch file. However i would recommend to use Apps --> System Tools --> Portable Finder CMD which is specifically designed to run custom batch scripts.

( Click to expand )

 ila_rendered

Press the "Edit" button and edit the scripts according to your needs. The batch file included with the script is just an example and you are free to completely remove all the lines and write your own custom script. As long as it's a valid CMD script, it will be executed at startup.


Re: What is %target_sys%? (another newbe question)
« Reply #2 on: April 28, 2015, 06:54:19 PM »

dcc

  • Jr. Chef
  • **
  • Date Registered: Apr 2015
  • Posts: 13
Thanks!!  I will try that immediately!

Re: What is %target_sys%? (another newbe question)
« Reply #3 on: April 28, 2015, 07:46:43 PM »

dcc

  • Jr. Chef
  • **
  • Date Registered: Apr 2015
  • Posts: 13
So I changed the text in there to read:
C:
cd \users\myuser\desktop\
myfile.exe

I rebuilt the PE iso image and booted it...
Nothing happened.
I opened a command prompt and it ran just fine.
:-<

Any ideas?

Re: What is %target_sys%? (another newbe question)
« Reply #4 on: April 29, 2015, 09:21:41 AM »

anshad

  • Chef
  • ***
  • Date Registered: Apr 2012
  • Posts: 323
Hi

Drivers letters are not static and may differ when you booted from a PE. The OS partition which has "C:" drive letter in Windows may be "D:" or "E:" in PE ( depending on the partition structure. If your goal is is to run an executable at startup ( ie, myfile.exe ), i would suggest ;

1. Run the executable in PE and make sure it is compatible and will run from a minimalist Windows environment like WinPE. If it shows errors, that means there are dependencies which need to be resolved.

2. Use "Components-->Additional files" script to include the executable in your build.

ila_rendered

Click on the "Open Source directory" button and you will see three folders named "DirCopy_All" , "DirCopy_x86" and "DirCopy_x64". As the name suggests x86 is for 32 bit builds and x64 is for 64 bit builds. Assuming that you are building a 32 bit PE, open "DirCopy_x86\Windows\System32" folder and copy your executable inside it. Any file you placed there will be copied to your boot disc's "System32" folder.

3. Now if you edit the "Portable finder CMD" and include a code similar to the below one, it will be executed on startup.

Code: [Select]
start "" "%windir%\system32\myfile.exe"
exit


Here is an example using nircmd.

Download nircmd (x86 or x64 depending on your build ) from http://www.nirsoft.net/utils/nircmd.html. Extract the zip and copy the nircmd.exe file via "Additional files" script (System32 folder ). Now edit the "Portable finder CMD" and change it to the below example.

Code: [Select]

nircmd infobox "Win7PE_SE base by ChrisR" "Welcome !"
exit

If you do it correctly, you will see a message box similar to the below one.

ila_rendered
« Last Edit: April 29, 2015, 09:48:58 AM by anshad »

Re: What is %target_sys%? (another newbe question)
« Reply #5 on: April 29, 2015, 12:52:51 PM »

dcc

  • Jr. Chef
  • **
  • Date Registered: Apr 2015
  • Posts: 13
Attempting it right now!!!


Thanks for the VERY detailed instructions..... I feel pretty confident now....

Re: What is %target_sys%? (another newbe question)
« Reply #6 on: April 29, 2015, 04:22:17 PM »

dcc

  • Jr. Chef
  • **
  • Date Registered: Apr 2015
  • Posts: 13
So the comenents-> additional files worked like a charm - my executables (and the nircmd) all made it into windows\system32 just fine.

However although I changed the cmd to

nircmd infobox "Win7PE_SE base by ChrisR" "Welcome !"
exit

It didn't fire up when I started the iso. :-{


I do have a lot of other things firing up, looking to startup network connections, though.

Any idea what else I might need to do?

Re: What is %target_sys%? (another newbe question)
« Reply #7 on: April 29, 2015, 04:40:20 PM »

anshad

  • Chef
  • ***
  • Date Registered: Apr 2012
  • Posts: 323
Are you sure "Portable Finder CMD" script is selected in your build ?. It's not selected by default so make sure it's included in your build.

Re: What is %target_sys%? (another newbe question)
« Reply #8 on: April 29, 2015, 04:52:10 PM »

dcc

  • Jr. Chef
  • **
  • Date Registered: Apr 2015
  • Posts: 13
Yes, I think I did it right.  Here is a picture:
 

Re: What is %target_sys%? (another newbe question)
« Reply #9 on: April 29, 2015, 05:08:45 PM »

anshad

  • Chef
  • ***
  • Date Registered: Apr 2012
  • Posts: 323
Can you check and confirm that "Portable Finder CMD" is present on the "System32" folder of PE ?. Also what happens when you type "nircmd.exe" and "Portable finder cmd.cmd" on a command prompt ?.

Re: What is %target_sys%? (another newbe question)
« Reply #10 on: April 29, 2015, 05:58:52 PM »

dcc

  • Jr. Chef
  • **
  • Date Registered: Apr 2015
  • Posts: 13
Further, once I have the PE booted, I can create a file called tryit.cmd
which looks just like the one above.
When I execute it, it works adn the window pops up.

Portable Finder CMD.cmd *does* exist in the x:\windows\system32 subdirectory.

When I try to execute it, by golly, it executes the nircmd just fine and the windows pops up!

Re: What is %target_sys%? (another newbe question)
« Reply #11 on: April 29, 2015, 06:01:17 PM »

dcc

  • Jr. Chef
  • **
  • Date Registered: Apr 2015
  • Posts: 13
One oddness, which might help explain things;
I am running this PE file from the hard disk, booting it up with grub2

Re: What is %target_sys%? (another newbe question)
« Reply #12 on: April 30, 2015, 05:33:29 AM »

anshad

  • Chef
  • ***
  • Date Registered: Apr 2012
  • Posts: 323
Can you try booting from a a USB stick or a Virtual Machine like Oracle VirtualBoX ?.

Re: What is %target_sys%? (another newbe question)
« Reply #13 on: April 30, 2015, 02:08:16 PM »

dcc

  • Jr. Chef
  • **
  • Date Registered: Apr 2015
  • Posts: 13
I just tried it in a VM.  No luck.

Re: What is %target_sys%? (another newbe question)
« Reply #14 on: April 30, 2015, 02:19:58 PM »

dcc

  • Jr. Chef
  • **
  • Date Registered: Apr 2015
  • Posts: 13
Don't know if this is helpful.  I Vmware it does not auto-run, but I have a lot of .cmd files in the system32 folder, (including the Portable Finder CMD.cmd).  When i execute (by hand) the latter, it does run fine.  But that autorun.cmd apparently *does* run at startup... HOw do I modify it?  and I have a startnet.cmd and an empty start.cmd as well.

Re: What is %target_sys%? (another newbe question)
« Reply #15 on: April 30, 2015, 02:42:17 PM »

dcc

  • Jr. Chef
  • **
  • Date Registered: Apr 2015
  • Posts: 13
It still looks to me like that "autorun.cmd" ought to be able to fix this.

I check the "AutoRun" box under Build, and it appears that there is a check to see if a file named autorun.cmd exists in the "target_sys" subdirectory.
On a guess, I have put such a file under the Target subdirectory, and I will see if that is what is meant by target_sys.

I have found this:
http://www.gregorystrike.com/2010/05/17/powershell-script-to-build-a-custom-winpe-v3-0-environment/
which creates a PE that does indeed allow me to autostart something, but without isolinux in it, I can't boot it from grub2, so it doesn't work for me, but it works fine in a VM.
It uses this script:
   if (Test-Path -path "$Mount\Program Files\System\Autostart.cmd"){
       Write-Host("Adding Autostart.cmd to startup...") -Fore 'Yellow'
       Add-Content -Path "$SystemPath\startnet.cmd" -Value """X:\Program Files\System\Autostart.cmd"""
   }
which apparently causes the startnet.cmd to execute the Autostart.cmd command.  I then create an autostart.cmd in the program files\system subdirectory, and "bob's your uncle".


Is there something similar I can do in WinBuilder?




 

Powered by EzPortal