none
How to execute a .bat file from within Sharepoint? RRS feed

  • Question

  • Hello Scripting Guys

        Using Sharepoint 2010 created using the UI there exists some "Links"
    on a page.

        Those links access other pages but there is a need for some of those
    links to run .bat files but I have not been able to find out how to write a
    link to execute a batch file.  I had tried this:

            "<a href="http:///<BatFileName.bat">http://<servername>/<BatFileName.bat>

        But when I click the link an error returns saying:

            "the following file(s) have been blocked by the administrator: /<BatFileName.bat>

        The .bat file is necessary because it contains lines that run .exe files,
    sets up printers, etc. so that when necessary to print the .bat file will already
    have setup the environment for printing.

        How can I accomplish this?

        Thank you
        Shabeaut

    Monday, July 7, 2014 4:06 PM

Answers

  • Monday, July 7, 2014 4:09 PM
  • You cannot run batch files on a SharePoint server from a link.  You can write a correctly designed program that can be called as a SharePoint application.

    If you are in doubt about this answer just post in the SharePoint developers forum for more detailed information.


    ¯\_(ツ)_/¯

    • Marked as answer by Shabeaut Monday, July 7, 2014 11:43 PM
    Monday, July 7, 2014 4:14 PM
  • The .bat file is necessary because it contains lines that run .exe files, sets up printers, etc. so that when necessary to print the .bat file will already have setup the environment for printing.

    Think about what you are asking. You are asking if you can click on a .bat file on a web site and have it run on your computer without downloading it. Imagine if this were possible! How fast would malware spread?

    Thus the answer is "no, you cannot do that" (for hopefully what is now a very obvious reason).

    The "lines that run .exe files, sets up printers, etc." is not something you should be trying to do from SharePoint. You should be using other administration methods to accomplish these tasks, such as Group Policy.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Shabeaut Monday, July 7, 2014 11:43 PM
    Monday, July 7, 2014 4:43 PM
    Moderator
  • You still cannot automatically execute a .bat file from a server on the local computer without downloading it to the local drive first.

    All that aside: If you are asking a SharePoint development question, then you can ask here:

    http://social.technet.microsoft.com/Forums/scriptcenter/en-Us/home?forum=sharepointdevelopment

    If you are asking an ASP.NET development question, you can ask here:

    http://forums.asp.net/

    This is not a SharePoint development forum or an ASP.NET development forum.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Shabeaut Monday, July 7, 2014 11:43 PM
    Monday, July 7, 2014 9:09 PM
    Moderator

All replies

  • Monday, July 7, 2014 4:09 PM
  • You cannot run batch files on a SharePoint server from a link.  You can write a correctly designed program that can be called as a SharePoint application.

    If you are in doubt about this answer just post in the SharePoint developers forum for more detailed information.


    ¯\_(ツ)_/¯

    • Marked as answer by Shabeaut Monday, July 7, 2014 11:43 PM
    Monday, July 7, 2014 4:14 PM
  • The .bat file is necessary because it contains lines that run .exe files, sets up printers, etc. so that when necessary to print the .bat file will already have setup the environment for printing.

    Think about what you are asking. You are asking if you can click on a .bat file on a web site and have it run on your computer without downloading it. Imagine if this were possible! How fast would malware spread?

    Thus the answer is "no, you cannot do that" (for hopefully what is now a very obvious reason).

    The "lines that run .exe files, sets up printers, etc." is not something you should be trying to do from SharePoint. You should be using other administration methods to accomplish these tasks, such as Group Policy.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Shabeaut Monday, July 7, 2014 11:43 PM
    Monday, July 7, 2014 4:43 PM
    Moderator
  • Hello jrv/Alex Brassington/Bill_Stewart

        Okay, when the word "portal" preceeds a different forest that forest is outside
    of Sharepoint making it is possible to execute a .bat file for example:

           "http://portal.MyForest.MyDomain.example.com>"
      
        The problem is that I don't know how to create a portal to do that.

        I took your advice and wrote an ASP.Net application, compiled it and ran
    it in Visual Studio 2008 and it ran just fine.

        I copied and pasted the url of the ASP.Net application into the Sharepoint
    link and clicke the link.

        But I get an error stating:

            "this page can't be displayed"
            "make sure the web address http is correct"
            "etc.

        This is encouraging but since the url contained localhost and a autgenerated
    port number my guess it that is why I got that error message.

        How can I get the Sharepoint "Link" to call the ASP.Net application successfully?

        Thank you
        Shabeaut

    Monday, July 7, 2014 9:04 PM
  • You still cannot automatically execute a .bat file from a server on the local computer without downloading it to the local drive first.

    All that aside: If you are asking a SharePoint development question, then you can ask here:

    http://social.technet.microsoft.com/Forums/scriptcenter/en-Us/home?forum=sharepointdevelopment

    If you are asking an ASP.NET development question, you can ask here:

    http://forums.asp.net/

    This is not a SharePoint development forum or an ASP.NET development forum.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Shabeaut Monday, July 7, 2014 11:43 PM
    Monday, July 7, 2014 9:09 PM
    Moderator