Page 1 of 1 1
Topic Options
#209289 - 2014-07-29 11:38 AM Trying to call an EXE
Fergieman Offline
Getting the hang of it

Registered: 2010-02-25
Posts: 58
Loc: Ireland
Guys

Im trying to run the following command via my script


Shell '%comspec% /c "C:\Program Files\Microsoft Dynamics CRM\Client\ConfigWizard\Microsoft.Crm.Application.Outlook.ConfigWizard.exe" /q/ i "C:\Program Files\Microsoft Dynamics CRM\Default_Client_Config.xml" '

But when I do I get 'C:\program' is not recognised as as internal or external command.

I can't figure out why this is happening. I believe I have all the quotes in the correct place.

Top
#209290 - 2014-07-29 12:08 PM Re: Trying to call an EXE [Re: Fergieman]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
Have you tried without the %comspec%?

It's always best to build the shell statement so that you can "see" what it is doing...

 Code:
$cmd="C:\Program Files\Microsoft Dynamics CRM\Client\ConfigWizard\Microsoft.Crm.Application.Outlook.ConfigWizard.exe" /q/ i "C:\Program Files\Microsoft Dynamics CRM\Default_Client_Config.xml"

? $cmd
;Shell $cmd

_________________________
(... better days ahead)

Top
#209291 - 2014-07-29 01:22 PM Re: Trying to call an EXE [Re: Fergieman]
Fergieman Offline
Getting the hang of it

Registered: 2010-02-25
Posts: 58
Loc: Ireland
I managed to re work this - I moved the location of the XML file to the root of the C drive and the command works fine. I can live with that.
Top
#209292 - 2014-07-29 02:43 PM Re: Trying to call an EXE [Re: Fergieman]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Building the string into a var eliminates the need for quotes at the Shell call and allows you to see the command that will run, as Allen has shown. I prefer to build $Cmd in stages though:
 Code:
$Cmd = '%COMSPEC% /c'
$Cmd = $Cmd + ' "C:\Program Files\Microsoft Dynamics CRM\Client\ConfigWizard\Microsoft.Crm.Application.Outlook.ConfigWizard.exe"'
$Cmd = $Cmd + ' /q /I "C:\Program Files\Microsoft Dynamics CRM\Default_Client_Config.xml"'

If $DEBUG
  'Command to run: ' @CRLF ' ' $Cmd @CRLF
Else
  Shell $Cmd
EndIf
Note that every time you extend the $CMD string, it starts with a SPACE character!. $DEBUG controls whether the command is displayed or executed.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#209303 - 2014-07-29 10:04 PM Re: Trying to call an EXE [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
And let me just say that I really do not like CRM. What a slow buggy piece of junk software Microsoft has there. It works overall but I really don't like using it or having to support it.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.067 seconds in which 0.035 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org