none
Can not find script file / cannot find script file: msbuild

    Question

  • Hi,

     

    I am trying to create a target in an MSBuild project that will recycle an app pool by using the iisapp.vbs script file.

    Here is the target definition:

     

    <Target Name="RecycleAppPool">

    <Exec Command="cscript c:\windows\system32\iisapp.vbs /a DefaultAppPool /r" WorkingDirectory="c:\windows\system32" ContinueOnError="true"/>

    <OnError ExecuteTargets="ErrorHandler"/>

    </Target>

     

    I have also tried it without the path of the vbs command right after the cscript command:

     

    <Target Name="RecycleAppPool">

    <Exec Command="cscript iisapp.vbs /a DefaultAppPool /r" WorkingDirectory="c:\windows\system32" ContinueOnError="true"/>

    <OnError ExecuteTargets="ErrorHandler"/>

    </Target>

     

    However, I get the message Can not find script file "c:\windows\system32\iisapp.vbs".

     

    If I try and run the command "cscript c:\windows\system32\iisapp.vbs" from the command prompt that I was trying to run the msbuild command on, then it works.  It just won't work when try and run it from within the MSbuild project file.

     

    I also get a similar message when trying to execute the script IIsCnfg.vbs from within the MSBuild project file.

     

    Is there something I am missing in terms of how to execute a script from within the MSBuild project file?

     

    Thanks for any help.
    Friday, December 14, 2007 10:19 PM

Answers

  • Have you figured the problem out?

    There seems nothing wrong in your project xml file. I copy it to my side, and have a quick test. All work fine.

    The following is result output from cmd:

     

    C:\Program Files\Microsoft Visual Studio 8\VC>msbuild C:\Test.csproj /t:RecycleA
    ppPool
    Microsoft (R) Build Engine Version 2.0.50727.1433
    [Microsoft .NET Framework, Version 2.0.50727.1433]
    Copyright (C) Microsoft Corporation 2005. All rights reserved.

    Build started 12/20/2007 7:25:27 PM.
    __________________________________________________
    Project "C:\Test.csproj" (RecycleAppPool target(s)):

    Target RecycleAppPool:
        cscript c:\windows\system32\iisapp.vbs  /a DefaultAppPool /r
        Microsoft (R) Windows Script Host Version 5.6
        Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.


    Build succeeded.
        0 Warning(s)
        0 Error(s)

    Time Elapsed 00:00:01.14

    C:\Program Files\Microsoft Visual Studio 8\VC>

     

    You need to make sure that iisapp.vbs locates in C:\windows\system32. I suggest you to copy it into a WordPad and save it in Text-Only format, and then copy it back. This will make all the characters in .csproj clear their formatting.

    Hope this helps

     

     

    Thanks

    Ji

    Thursday, December 20, 2007 11:42 AM
    Moderator

All replies

  • Have you figured the problem out?

    There seems nothing wrong in your project xml file. I copy it to my side, and have a quick test. All work fine.

    The following is result output from cmd:

     

    C:\Program Files\Microsoft Visual Studio 8\VC>msbuild C:\Test.csproj /t:RecycleA
    ppPool
    Microsoft (R) Build Engine Version 2.0.50727.1433
    [Microsoft .NET Framework, Version 2.0.50727.1433]
    Copyright (C) Microsoft Corporation 2005. All rights reserved.

    Build started 12/20/2007 7:25:27 PM.
    __________________________________________________
    Project "C:\Test.csproj" (RecycleAppPool target(s)):

    Target RecycleAppPool:
        cscript c:\windows\system32\iisapp.vbs  /a DefaultAppPool /r
        Microsoft (R) Windows Script Host Version 5.6
        Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.


    Build succeeded.
        0 Warning(s)
        0 Error(s)

    Time Elapsed 00:00:01.14

    C:\Program Files\Microsoft Visual Studio 8\VC>

     

    You need to make sure that iisapp.vbs locates in C:\windows\system32. I suggest you to copy it into a WordPad and save it in Text-Only format, and then copy it back. This will make all the characters in .csproj clear their formatting.

    Hope this helps

     

     

    Thanks

    Ji

    Thursday, December 20, 2007 11:42 AM
    Moderator
  • Hi Ji.

     

    As  was about to reply that I have not figured this out, I got an idea that I tested and now know what the problem is, though now another one has appeared.

     

    As per this posting: http://www.eggheadcafe.com/forumarchives/win32programmerkernel/Aug2005/post23471841.asp",  32-bit apps trying to read or write to c:\windows\system32 are redirected to c:\windows\SysWOW64 instead"

     

    So the problem is that although I am telling it to use system32, it is looking in syswow64.  And there is no iisapp.vbs script in that folder.  So I copied the script to that folder and now I get a different error.

     

    The part of the script that attempts to create Microsoft.CmdLib object fails.

     

    I don't know enough about the internals to understand why it works in 1 folder but not another.

     

    Perhaps this deserves its own post but if you have any ideas on why this problem exists or how to fix it, please reply.

     

    Thanks.

     

     

    I

    Friday, December 21, 2007 8:42 PM
  • What I did is I copied the 2 files

    -cscript.exe

    -iisapp.vbs

     

    to a different directory .. for example D:\Build\

     

    Then I modify my working directory in my MSBuild to D:\Build\ and it worked.

    Friday, April 11, 2008 10:02 AM
  • Hi,
    I have the same problem on Server 2003 X64 Enterprise Ed.

    For me is not working from Command Prompt neither.

    I tried to copy the files on another location but now i get the following error :

    Could not create an instance of the CmdLib object.
    Please register the Microsoft.CmdLib component.

    How do i register that ?

    Thanks.


    I did some research and i think i solved the problem:


    I copyed the cscript.exe, iisweb.vbs, IIsScHlp.wsc and cmdlib.wsc files to C:\WINDOWS\SysWOW64 folder.
    i registere the IIsScHlp.wsc and cmdlib.wsc using regsvr32 and now it works from CMD Prompt:


    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

    Connecting to server ...Done.
    Site(s) not found.

    • Proposed as answer by LoLuTz Friday, April 10, 2009 9:13 AM
    Friday, April 10, 2009 9:04 AM