Jump to content











Photo
- - - - -

Autostart cmd file


  • Please log in to reply
10 replies to this topic

#1 esgaroth

esgaroth

    Frequent Member

  • .script developer
  • 173 posts
  •  
    United States

Posted 24 November 2008 - 07:57 AM

I am trying to use AddPostConfig to run a cmd file automatically. I can get it to run an exe file just fine but not a cmd file.
I tried using cmd.exe with my cmd file as an argument. Here is the command that I am trying to use:

AddPostConfig,"ghost","cmd.exe","/c %ProgramFiles%\ghost\ghost.cmd"

the cmd file runs a couple of commands as well as starting ghost with some switches. I also put in a pause command at the end so I could see if there were any errors running the script. But the file never runs. I can navigate to the cmd file and run it manually and it works fine.
An exe file works fine if I use this:

AddPostConfig,"ghost","ghost32.exe"

I tried using this to test running cmd.exe with arguments:

AddPostConfig,"cmd","cmd.exe","/k ping -t www.yahoo.com"

This also does nothing.
I also tried this:

AddPostConfig,"cmd","cmd.exe"

Witch I would expect to open a command prompt but doesnt.
I can use the run dialog box to run any of the above commands just fine. It seems that I just cant autorun cmd.exe.
I may be missing something obviously stupid. If so then please let me know what it is.

Also when I use the AddPostConfig where does it put the startup information. I would like to see exactly how the command to start my program looks after it has been written into the wim file.

#2 MichaelZ

MichaelZ

    Frequent Member

  • Team Reboot
  • 333 posts
  • Location:Braunschweig, Germany
  •  
    Germany

Posted 24 November 2008 - 10:19 AM

Hi esgaroth,

I'm not sure if it is possible what you want. The problem is not starting cmd.exe, this should be possible specifying the full path
X:\Windows\System32\cmd.exe
If you don't specify the full path of the executable, VistaPE API thinks that it resides in the program path. So as an alternative you could additionally copy cmd.exe into the ghost directory.

The bigger problem is to specify where your batch file resides. If you load the program directory into ram, you could specify it as
"X:\Program Files\Ghost\ghost.cmd"
If you choose to run it from cd drive I'm not sure if it will work when you specify it as
"%Target_Prog%\ghost.cmd"
Another possibility would be
"%PE_Programs%\%ProgramFolder%\ghost.cmd"
(if you have specified %ProgramFolder% in your section Variables, otherwise replace it with the name of your directory ghost).

To see the results of your script coding have a look at the end of vistape.cfg in X:\Windows\System32. If you want to check before booting your VistaPE, mount your vistape.wim that is located in the target directory.

Many Greetings
MichaelZ

#3 esgaroth

esgaroth

    Frequent Member

  • .script developer
  • 173 posts
  •  
    United States

Posted 24 November 2008 - 06:56 PM

I've been trying to get this to work with no luck. The vistape.cfg file has definitely helped me to see what my script is doing though.

First I tried this:
AddPostConfig,"ghost32","x:\windows\system32\cmd.exe","/k x:\Program Files\ghost\ghost.cmd"
which resulted in this in the vistape.cfg:
wait|ghost32|x:\windows\system32\cmd.exe /k x:\Program Files\ghost\ghost.cmd

That does nothing probably because there is a space in program files.


So then I tried this in my script:
AddPostConfig,"ghost32","x:\windows\system32\cmd.exe",/k "x:\Program Files\ghost\ghost.cmd"
Which results in this:
wait|ghost32|x:\windows\system32\cmd.exe /k
That is obviously no good.

My last attempt is this one:
AddPostConfig,"ghost32","x:\windows\system32\cmd.exe","/k "x:\Program Files\ghost\ghost.cmd""
Which for some reason gives this as its result:
x:\Program Files\ghost\ghost.cmd"|ghost32|x:\windows\system32\cmd.exe /k
Definately no good.

I know that I need the vistape.cfg to have something like this:
wait|ghost32|x:\windows\system32\cmd.exe /k "x:\Program Files\ghost\ghost.cmd"
But I dont know what to put in my script to get this.

#4 MedEvil

MedEvil

    Platinum Member

  • .script developer
  • 7771 posts

Posted 24 November 2008 - 07:55 PM

I don't use VistaPE, so feel free to ignore me. :) But how about trying first with a path without spaces, just to make sure, that it's really the spaces that cause the problem. ?

:(

#5 esgaroth

esgaroth

    Frequent Member

  • .script developer
  • 173 posts
  •  
    United States

Posted 24 November 2008 - 08:12 PM

ok, I made some changes to try and get a work around working but I'm having no luck. I put my cmd file in the custom folder. I put it in windows\system32. I have confirmed that the file does exist there after vistape boots. In my script file I have this:

AddPostConfig,"ghost32","x:\windows\system32\cmd.exe","/k x:\windows\system32\ghost.cmd"

Which puts this into my vistape.cfg file:

wait|ghost32|x:\windows\system32\cmd.exe /k x:\windows\system32\ghost.cmd

that looks good and I expected it to work but nothing happens.
I can type that exact command into the run box and it works.

#6 MedEvil

MedEvil

    Platinum Member

  • .script developer
  • 7771 posts

Posted 24 November 2008 - 08:54 PM

If VistaPE works anything like XPPE, timing might make all the difference.
If i understand you right, you want to auto execute the command at boot. Which does not work.
But later you can use it without problems.

Maybe something is not yet properly configured, when autorun tries to start it. ?

I would take the command apart and try it piece by piece to see which part fails, or if they just don't work together.

:)

#7 MedEvil

MedEvil

    Platinum Member

  • .script developer
  • 7771 posts

Posted 24 November 2008 - 09:01 PM

What happens if you double click autostart.cmd after boot up is complete? Does your command work then, or still not?

:)

#8 esgaroth

esgaroth

    Frequent Member

  • .script developer
  • 173 posts
  •  
    United States

Posted 24 November 2008 - 09:39 PM

both double clicking on my ghost.cmd file and typing the command "x:\windows\system32\cmd.exe /k x:\windows\system32\ghost.cmd" as it is shown in the vistape.cfg file into the run box work fine.
Currently just for testing my cmd file contains nothing but the command "pause".

#9 esgaroth

esgaroth

    Frequent Member

  • .script developer
  • 173 posts
  •  
    United States

Posted 24 November 2008 - 11:08 PM

So it doesnt appear to have anything to do with my cmd file. I tried this line in my script:
AddPostConfig,"ghost32","x:\windows\system32\cmd.exe","/k x:\windows\system32\ghost32.exe"
This does nothing as well. The resulting line in my vistape.cfg is:
wait|ghost32|x:\windows\system32\cmd.exe /k x:\windows\system32\ghost32.exe
It appears that I cannot send another program to cmd.exe at boot. As usual typing this command directly into the run box works fine.

I can however send an argument to cmd.exe. The following line works as expected.
AddPostConfig,"ghost32","x:\windows\system32\cmd.exe","/k ping -t www.yahoo.com"
This ends up in my vistape.cfg file:
wait|ghost32|x:\windows\system32\cmd.exe /k ping -t www.yahoo.com
The command prompt comes up and starts pinging.

#10 MedEvil

MedEvil

    Platinum Member

  • .script developer
  • 7771 posts

Posted 24 November 2008 - 11:53 PM

You can try:
AddPostConfig,"ghost32","x:\windows\system32\cmd.exe","start /B x:\windows\system32\ghost32.exe"
or maybe even:
AddPostConfig,"ghost32","x:\windows\system32\cmd.exe","/k start /B x:\windows\system32\ghost32.exe"

The /B is not really necessary in this case, but probably recommended with the .cmd file.

:)

#11 ludovici

ludovici

    Silver Member

  • .script developer
  • 610 posts
  • Location:France
  •  
    France

Posted 25 November 2008 - 07:41 PM

Hello everybody :)

AddAutoRun,"Ghost","X:\Program files\ghost\ghost.cmd","",4




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users