5

I am using wix and want to call command line after installation.

How can I do this?

My command line is here "bcdedit.exe /set {current} nx AlwaysOff" // this makes dep off

Yes, I've read about custom actions, but I didn't see any example with command line.

P.S. bcdedit is usual exe in Win 7 and higher.

P.S. currently I have next script and it does not work:

          Directory  ="INSTALLLOCATION"
          ExeCommand ='echo hello> echo_test.txt'
          Execute    ="immediate"
          Return     ="asyncNoWait"
                />
Alex Blokha
  • 1,141
  • 2
  • 17
  • 30
  • can you give the detail of error and the code you have used – vinay Sep 30 '11 at 12:27
  • 3
    Ew, changing a global setting of the machine like that is not something an average installation should do. Perhaps this is okay within a company, but if some app did this to my machine I would be unhappy. – Michael Urman Sep 30 '11 at 19:22

3 Answers3

11

echo is not an executable, it is the command of the command processor cmd.exe. Change your ExeCommand value to cmd.exe /c "echo hello >echo_test.txt".

Your echo_test.txt would be in an arbitrary directory, you have to use absolute paths to get predictable results.

Alexey Ivanov
  • 11,541
  • 4
  • 39
  • 68
6

Ok, this example works...

<CustomAction Id         ="echo_test"                     
              Directory  ="INSTALLLOCATION"
              ExeCommand ='NOTEPAD.EXE echo_test.txt'
              Execute    ="immediate"
              Return     ="asyncNoWait"
                    />

My test example with echo didn't worked for some reason. And bcdedit does not exist on WinXP, where I am testing now...

Alex Blokha
  • 1,141
  • 2
  • 17
  • 30
  • So this code does work, doesn't it? If yes, you should accept it as the answer. And [my answer](http://stackoverflow.com/questions/7609012/call-command-line-after-installation-in-wix/7614565#7614565) explains why it didn't work with `echo`. – Alexey Ivanov Oct 04 '11 at 17:12
2

Hi there are lots of example available on net...

try these links

http://wix.sourceforge.net/manual-wix2/qtexec.htm

Execute Command Line In WiX Script?

WiX - CustomAction ExeCommand - Hide Console

Or try this example:

 <CustomAction Id="SetQtExecCmd" Property="SetQtExec"
       Value="&quot;[PutPathOfThisFileHere]bcdedit.exe&quot; /set {current} nx AlwaysOff" />
<CustomAction Id="SetQtExec" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="immediate" Return="check" />
Community
  • 1
  • 1
vinay
  • 1,004
  • 1
  • 11
  • 27
  • it says: Error 2 The CustomAction/@BinaryKey attribute's value, ' ', is not a legal identifier. Identifiers may contain ASCII characters A-Z, a-z, digits, underscores (_), or periods (.). Every identifier must begin with either a letter or an underscore. Its because it is empty. Yes, Ive seen those links. And I didn't see any working example for command line, not for single exe. – Alex Blokha Sep 30 '11 at 11:35
  • yes that is because the **BinaryKey** was empty...i have updated my answer ...check it out – vinay Sep 30 '11 at 12:23
  • I've used your example, but for some reasons when I use it, my installation fails. I've found correct answere. – Alex Blokha Sep 30 '11 at 14:32
  • The first correct answer was from me. But I still need working example for command "bcdedit.exe /set {current} nx AlwaysOff>>log.txt" – Alex Blokha Oct 06 '11 at 12:06