Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Use sendMessage and Findwindow with VBscript

Use sendMessage and Findwindow with VBscript

Scheduled Pinned Locked Moved Visual Basic
csharpasp-netquestion
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Ibana
    wrote on last edited by
    #1

    Hi, I have an web application running on a applicationserver. Now I want to shutdown local software on the client from the browser. I use asp.net but I realized I needed av VBscript to execute on the local client to be able to get a handle for the local applicaition that I want to shutdown. But how do I use the WINAPI methods sendMessage and findWindow in VBscript. I know I have to import user32.dll. Im really bad at scripting...) THANKS! Ibana

    D 1 Reply Last reply
    0
    • I Ibana

      Hi, I have an web application running on a applicationserver. Now I want to shutdown local software on the client from the browser. I use asp.net but I realized I needed av VBscript to execute on the local client to be able to get a handle for the local applicaition that I want to shutdown. But how do I use the WINAPI methods sendMessage and findWindow in VBscript. I know I have to import user32.dll. Im really bad at scripting...) THANKS! Ibana

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      VBScript, or any script running in a browser for that matter, has absolutely no access to the Win32 Api. It's impossible to do what you want from inside a browser session without the user downloading, installing, and allowing script to execute, a custom COM object that does the same thing. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      I U 2 Replies Last reply
      0
      • D Dave Kreskowiak

        VBScript, or any script running in a browser for that matter, has absolutely no access to the Win32 Api. It's impossible to do what you want from inside a browser session without the user downloading, installing, and allowing script to execute, a custom COM object that does the same thing. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        I Offline
        I Offline
        Ibana
        wrote on last edited by
        #3

        thanks for your replay, Do you have any suggestion how to access the winapi on the local machine from my asp.net/C# application running on a server. I need to use the winapi to shutdown a local installed software. Should a make a small app that runs on the local machine that calls the winapi? Are there any better solutions? /ibana

        D 1 Reply Last reply
        0
        • I Ibana

          thanks for your replay, Do you have any suggestion how to access the winapi on the local machine from my asp.net/C# application running on a server. I need to use the winapi to shutdown a local installed software. Should a make a small app that runs on the local machine that calls the winapi? Are there any better solutions? /ibana

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          There is NOTHING in your ASP.NET code that can get to the client machine. It's IMSPOSSIBLE. Your app will have absolutely no permissions onthe local machine. Also, script running inside a browser session will not have any access to other processes running outside the browser session and has no access to any client hardware or system resources. The user MUST install a component to do this, and it will ONLY work if security inside the browser is stripped down to nothing! Your web app cannot stop a process outside the browser, period, unless the user turns the security for the zone your code came from down to nothing! This is something that no sane network admin on earth would do! RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          • D Dave Kreskowiak

            VBScript, or any script running in a browser for that matter, has absolutely no access to the Win32 Api. It's impossible to do what you want from inside a browser session without the user downloading, installing, and allowing script to execute, a custom COM object that does the same thing. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            U Offline
            U Offline
            User 11973506
            wrote on last edited by
            #5

            I know this is a bit old discussion, but thought of sharing this: Info/Theory: ~~~~~~~~~~~ User32.dll is the source of many of the most common Windows API's, that allow you to interact with the operating system at a lower level. Please check: https://social.msdn.microsoft.com/Forums/windows/en-US/b04153ff-e4fb-4500-a8e4-3a685208af57/when-to-use-user32dll-and-how?forum=winforms Following is the code to access Win32 API using VBSCript. --------------------------------------------------------- ' --------------- Start of Code ------------------------------------------------------------ Dim excel Set excel = CreateObject("Excel.Application") Dim strMacro strMacro = "CALL('user32', 'MessageBoxA', 'JJCCJ', 0, 'Hello, Win32 API(VBScript) World - My call via User32 dll!', 'Hello, World!', 0)" strMacro = Replace( strMacro, "'", """" ) excel.ExecuteExcel4Macro( strMacro ) '---------------- End of Code -------------------------------------------------------------- Copy the above to a notepad & save it as : myMessage.vbs and double click it. Expected Result: Please see the script in action : Windows API VBScript Calling User32 DLL directly - YouTube[^]

            D 1 Reply Last reply
            0
            • U User 11973506

              I know this is a bit old discussion, but thought of sharing this: Info/Theory: ~~~~~~~~~~~ User32.dll is the source of many of the most common Windows API's, that allow you to interact with the operating system at a lower level. Please check: https://social.msdn.microsoft.com/Forums/windows/en-US/b04153ff-e4fb-4500-a8e4-3a685208af57/when-to-use-user32dll-and-how?forum=winforms Following is the code to access Win32 API using VBSCript. --------------------------------------------------------- ' --------------- Start of Code ------------------------------------------------------------ Dim excel Set excel = CreateObject("Excel.Application") Dim strMacro strMacro = "CALL('user32', 'MessageBoxA', 'JJCCJ', 0, 'Hello, Win32 API(VBScript) World - My call via User32 dll!', 'Hello, World!', 0)" strMacro = Replace( strMacro, "'", """" ) excel.ExecuteExcel4Macro( strMacro ) '---------------- End of Code -------------------------------------------------------------- Copy the above to a notepad & save it as : myMessage.vbs and double click it. Expected Result: Please see the script in action : Windows API VBScript Calling User32 DLL directly - YouTube[^]

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              That's cute and all, but it also requires Office be installed on the machine in order to work and that's not going to be the case on every machine. Frankly, using Excel as an intermediary just to run a single line of code is a very heavy cost and a bit ridiculous.

              Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
              Dave Kreskowiak

              U 1 Reply Last reply
              0
              • D Dave Kreskowiak

                That's cute and all, but it also requires Office be installed on the machine in order to work and that's not going to be the case on every machine. Frankly, using Excel as an intermediary just to run a single line of code is a very heavy cost and a bit ridiculous.

                Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
                Dave Kreskowiak

                U Offline
                U Offline
                User 11973506
                wrote on last edited by
                #7

                This only happens if you have any of the following type of laptops: a) Mac / MacBook with IoS b) Laptop used exclusively for non-MS office testing c) New Laptop with no MS Office Installed d) Loaner laptop with no MS Office e) Sometimes if you have had a crash of MS Office on your laptop - then also the Excel Application will not work - for this. f) if your enterprise IT has disabled using MS Office COM Objects and/or restricted authorization to use MS Office COM objects/APIs. ELSE I do not know of any other reason - any laptop not having MS Office installed. But the solution does work - and you do not need to use any other tools. :thumbsup: Good luck.

                D 1 Reply Last reply
                0
                • U User 11973506

                  This only happens if you have any of the following type of laptops: a) Mac / MacBook with IoS b) Laptop used exclusively for non-MS office testing c) New Laptop with no MS Office Installed d) Loaner laptop with no MS Office e) Sometimes if you have had a crash of MS Office on your laptop - then also the Excel Application will not work - for this. f) if your enterprise IT has disabled using MS Office COM Objects and/or restricted authorization to use MS Office COM objects/APIs. ELSE I do not know of any other reason - any laptop not having MS Office installed. But the solution does work - and you do not need to use any other tools. :thumbsup: Good luck.

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  First, using a heavy weight application, like Excel, to call a couple of Win32 API's is ridiculous. Also, going back to the original context of the question, the script, running in a browser, can NOT create an instance of Excel. COM-interop is off-limits because of security concerns. It's also the reason ActiveX is no longer supported by browsers.

                  Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
                  Dave Kreskowiak

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups