run vb script file without prompting to open/save

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AnuSumesh
    New Member
    • Aug 2007
    • 96

    run vb script file without prompting to open/save

    Hi,

    I am ridirecting page to vbs file.
    File is running properly but it is asking user to open/save the file.
    But i want that it should run without any dialouge box.

    My code is :

    <%@language="vb script" %>

    <% dim a

    a=request.form( "sometextbo x")
    if a="" then
    %>
    <html>
    <body>

    --------some code -------
    </body>
    </html>

    <%
    else
    response.redire ct("file.vbs")
    end if
    %>

    It is first asking me to open or save the file.
    If i click "open" then it asks to run or don't Run

    But i want it to run directly without any user input.

    Can anyone help me in this issue.
    Thanks in advance.

    Anu
  • JamieHowarth0
    Recognized Expert Contributor
    • May 2007
    • 537

    #2
    Hi Anu,

    The problem you face is that you have to get your web server to process the VB code in the file, before serving the resulting HTML code back to the user (exactly the same as an ASP file), otherwise you will end up with your user viewing all of your lovely VB code in their browser and feeling horribly confused...

    You get round this by doing the following:
    1. Go into Internet Information Services.
    2. Right-click on the website serving the VBS file and click Properties.
    3. Select the Home Directory tab, and down the bottom, click Configuration.
    4. Click Add
    5. In Extension, type "vbs" (without the quotes), and in Executable, type C:\Windows\syst em32\inetsrv\as p.dll
    Your server will now process VBS files in the same manner as ASP files, and should process as normal.


    Failing that, just rename your file to a file extension of ".asp"!

    Best regards,

    medicineworker

    Comment

    • AnuSumesh
      New Member
      • Aug 2007
      • 96

      #3
      Hi Medicineworker,


      First of all thanks for reply.

      My vbs file is executing without any problem.
      Main thing is i dont want "file download-security warning" dialogue which is asking me to open/save the file.
      I want to execute the file without user intervention.

      I tried the way u told: but in this way it does not execute the file but it is displaying the whole code of vbs file into browser. and that is really horrible.

      I am giving u the code for my vbs file:
      abc.vbs -this is to call remote desktop of particular IP:

      On Error Resume Next

      Dim ForReading

      Dim Filename,fil,fo ld
      Filename="C:\te mp.txt"

      ForReading = 1
      Set objFSO = CreateObject("S cripting.FileSy stemObject")

      set fil=objFSO.GetF ile("c:\temp.tx t")

      If objFSO.FileExis ts(Filename) Then

      Set objTextFile = objFSO.OpenText File _
      (Filename, ForReading)

      IP=objTextFile. ReadLine
      objTextFile.clo se

      'Delete the temporary file
      fil.delete(true )

      'Call RDP

      dim wshell
      set wshell=CreateOb ject("WScript.S hell")
      wshell.Run "C:\windows\sys tem32\mstsc.exe /v:"& IP
      set wshell=nothing
      End If

      this is executing fine but needs user intervention that i dont want.

      Your help is very much appreciated. Thank you.

      Anu.

      Comment

      • jhardman
        Recognized Expert Specialist
        • Jan 2007
        • 3405

        #4
        Anu,

        Can you change the file extension to .ASP ?

        Jared

        Comment

        • AnuSumesh
          New Member
          • Aug 2007
          • 96

          #5
          Hi Jared

          Thanks for reply.
          I changed the extension to asp. but then it is displaying the contents of the file as it is in the browser.

          Thanks,
          Anu

          Comment

          • jhardman
            Recognized Expert Specialist
            • Jan 2007
            • 3405

            #6
            Anu,

            How are you navigating to the page? It sounds like you are just opening it with explorer.

            Jared

            Comment

            • AnuSumesh
              New Member
              • Aug 2007
              • 96

              #7
              Originally posted by jhardman
              Anu,

              How are you navigating to the page? It sounds like you are just opening it with explorer.

              Jared
              Hi Jared,

              I am using
              response.redire ct("file.vbs")
              to execute vbs file. this vbs file is to run exe file for remote desktop.
              As u told to change the extension to asp. I tried it as follows:
              response.redire ct("file.asp")
              but then it was displaying the contents of the file on the browser.

              Please help me in this issue.

              Thanks

              Anu

              Comment

              • jhardman
                Recognized Expert Specialist
                • Jan 2007
                • 3405

                #8
                Anu,

                From where are you redirecting? from another .ASP or .VBS page?

                Jared

                Comment

                • AnuSumesh
                  New Member
                  • Aug 2007
                  • 96

                  #9
                  Originally posted by jhardman
                  Anu,

                  From where are you redirecting? from another .ASP or .VBS page?

                  Jared
                  Hi Jared,

                  I have given the code for my first asp page in my first post.
                  from that page i m redirecting to vbs page.
                  vbs file is executing properly but browser asks me to open/save the file first 'n' then if i click "open" then it asks to run/don't run. If i click "run" then vbs file executes.
                  I dont want these dialouge boxes( open/save and run/don't ).

                  Thanks,

                  Anu

                  Comment

                  • jhardman
                    Recognized Expert Specialist
                    • Jan 2007
                    • 3405

                    #10
                    Anu,

                    What you are saying doesn't make sense, and I get the feeling I'm missing something, that's why I keep asking to reiterate basic questions. The code you have posted is the correct code, it is the correct code I use all the time, and I never have that problem. There are only a few reasons that a server would not display the script correctly:

                    - If the file extension is not something it recognizes, the server will prompt you to download (save or open). But if it recognizes the file extension for the first file and executes the code correctly, it shouldn't have a problem with the second (as long as the two files have the same file extension). You said the first page was an asp page, so the second one should be too.

                    - If the file is being opened by windows explorer instead of through an internet connection, but using a response.redire ct statement should prevent that.

                    - If scripting is turned off for a particular file type. Somewhere deep in server settings is the option to turn on or off scripting for different types of files. Medicineworker' s instructions above tell how to turn on scripting for this file type. His instructions should work perfectly. I should probably mention that scripting can also be turned off for some folders, but as long as both files are in the same folder, I don't see how this could contribute to the problem.

                    Besides that, I can't see why there would be a problem.

                    Jared

                    Comment

                    • AnuSumesh
                      New Member
                      • Aug 2007
                      • 96

                      #11
                      Hi Jared,

                      Please find my answers with ur points:
                      Originally posted by jhardman
                      What you are saying doesn't make sense, and I get the feeling I'm missing something, that's why I keep asking to reiterate basic questions. The code you have posted is the correct code, it is the correct code I use all the time, and I never have that problem. There are only a few reasons that a server would not display the script correctly:

                      - If the file extension is not something it recognizes, the server will prompt you to download (save or open). But if it recognizes the file extension for the first file and executes the code correctly, it shouldn't have a problem with the second (as long as the two files have the same file extension). You said the first page was an asp page, so the second one should be too.
                      anu- both files have different extensions. first one is asp 'n' second one is vbs

                      Originally posted by jhardman
                      - If the file is being opened by windows explorer instead of through an internet connection, but using a response.redire ct statement should prevent that.
                      anu - file is opened through internet connection
                      Originally posted by jhardman
                      - If scripting is turned off for a particular file type. Somewhere deep in server settings is the option to turn on or off scripting for different types of files. Medicineworker' s instructions above tell how to turn on scripting for this file type. His instructions should work perfectly. I should probably mention that scripting can also be turned off for some folders, but as long as both files are in the same folder, I don't see how this could contribute to the problem.
                      anu - if i m following Medicineworker' s instructions , then it just displaying the contents of vbs file in the browser.
                      Originally posted by jhardman
                      Besides that, I can't see why there would be a problem.

                      Jared


                      Can u plz help me now?

                      Thanks a lot

                      Regards,
                      Anu
                      Last edited by jhardman; Dec 30 '07, 10:05 PM. Reason: put quotes in quote tags

                      Comment

                      • jhardman
                        Recognized Expert Specialist
                        • Jan 2007
                        • 3405

                        #12
                        Originally posted by AnuSumesh
                        ...
                        both files have different extensions. first one is asp 'n' second one is vbs
                        ...
                        Can u plz help me now?

                        Thanks a lot

                        Regards,
                        Anu
                        The file extension of BOTH files should be ".asp". ASP is a vbs file that a web server can execute. Change the file extension to .asp AND change the response.redire ct line to reflect that change. Let me know if that helps.

                        Jared

                        Comment

                        • AnuSumesh
                          New Member
                          • Aug 2007
                          • 96

                          #13
                          Originally posted by jhardman
                          The file extension of BOTH files should be ".asp". ASP is a vbs file that a web server can execute. Change the file extension to .asp AND change the response.redire ct line to reflect that change. Let me know if that helps.

                          Jared
                          Hi Jared,

                          I have already tried this option.
                          After changing the extension to asp and also change is made in response.redire ct line i.e response.redire ct("runfile.asp ")
                          it is displaying the contents of file in browser rather than executing the script.

                          contents of runfile.vbs file are:

                          On Error Resume Next

                          Dim ForReading

                          Dim Filename,fil,fo ld
                          Filename="C:\te mp.txt"

                          ForReading = 1
                          Set objFSO = CreateObject("S cripting.FileSy stemObject")

                          set fil=objFSO.GetF ile("c:\temp.tx t")

                          If objFSO.FileExis ts(Filename) Then

                          Set objTextFile = objFSO.OpenText File _
                          (Filename, ForReading)

                          IP=objTextFile. ReadLine
                          objTextFile.clo se

                          'Delete the temporary file
                          fil.delete(true )

                          'Call RDP

                          dim wshell
                          set wshell=CreateOb ject("WScript.S hell")
                          wshell.Run "C:\windows\sys tem32\mstsc.exe /v:"& IP
                          set wshell=nothing
                          End If

                          Please suggest me any other option. I got stuck here.

                          I have read in one of the forums that for running vbs file from asp file we have to set some MIME type. But what should be the MIME type for executing vbs file from asp file?

                          Can u please provide your valuable help ?

                          Thanks 'n' Regards,
                          Anu

                          Comment

                          • jhardman
                            Recognized Expert Specialist
                            • Jan 2007
                            • 3405

                            #14
                            Clear the cache or check from a different computer. It is possible that your computer has stored the old version and isn't allowing the server to send the new version. I can't think of anything else. Maybe you could post in the IIS forum.

                            Jared

                            Comment

                            • AnuSumesh
                              New Member
                              • Aug 2007
                              • 96

                              #15
                              Originally posted by jhardman
                              Clear the cache or check from a different computer. It is possible that your computer has stored the old version and isn't allowing the server to send the new version. I can't think of anything else. Maybe you could post in the IIS forum.

                              Jared
                              Hi Jared,

                              Thanks first of all. I have posted this on IIS now.
                              My only purpose is to call RDP on click of link.

                              'n' I have solved my problem temporarily by calling javascript function instead of vbs file as follows:
                              <script language="javas cript">
                              function setip(ip)
                              {
                              var wshell;
                              wshell=new ActiveXObject(" WScript.Shell") ;
                              wshell.Run("C:\ \windows\\syste m32\\mstsc.exe /v:"+ip);
                              }
                              </script>
                              <body>
                              <a href="#" onclick="javasc ript:setip('192 .20.31.1')"> RDP </a>
                              </body>

                              is it correct way of doing?
                              in above code mstsc,exe should be present in client side.

                              But I have one doubt related to msctc.exe file in case of vbs file.
                              In the vbs file i am running mstsc.exe file as follows:
                              wshell.Run "C:\windows\sys tem32\mstsc.exe /v:"& IP

                              I want to ask that the file mstsc.exe used for RDP is called from client side or from server side?
                              If it is at client side 'n' in case it is not available at client side then how can i download it from server side?

                              Please provide me your valuable help.

                              Thanks again.

                              Regards,
                              Anu

                              Comment

                              Working...