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. help to Convert this VBA into a vbscript

help to Convert this VBA into a vbscript

Scheduled Pinned Locked Moved Visual Basic
help
2 Posts 2 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.
  • S Offline
    S Offline
    SPGV
    wrote on last edited by
    #1

    VBA module Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadId As Long End Type Type STARTUPINFO cb As Long lpReserved As String lpDesktop As String lpTitle As String dwX As Long dwY As Long dwXsize As Long dwYsize As Long dwXCountChars As Long dwYCountChars As Long dwFillAttribute As Long dwFlags As Long wShowWindow As Integer cbReserved2 As Integer lpReserved2 As Long hStdInput As Long hStdOutput As Long hStdError As Long End Type Declare Function CloseHandle Lib "kernel32" (hObject As Long) As Boolean Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hObject As Long, ByRef dwExitCode As Long) As Boolean Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long 'Public Sub ShellAndWait(AppToRun)As Integer Function ShellAndWait(AppToRun) As Integer Dim NameOfProc As PROCESS_INFORMATION Dim NameStart As STARTUPINFO Dim rc As Long Dim dwExitCode As Long dwExitCode = -1 ShellAndWait = dwExitCode NameStart.cb = Len(NameStart) rc = CreateProcessA(0&, AppToRun, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, NameStart, NameOfProc) rc = WaitForSingleObject(NameOfProc.hProcess, INFINITE) rc = GetExitCodeProcess(NameOfProc.hProcess, dwExitCode) MsgBox "ExitCode for the process is, dwExitCode = " & dwExitCode ShellAndWait = dwExitCode rc = CloseHandle(NameOfProc.hProcess) End Function

    E 1 Reply Last reply
    0
    • S SPGV

      VBA module Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadId As Long End Type Type STARTUPINFO cb As Long lpReserved As String lpDesktop As String lpTitle As String dwX As Long dwY As Long dwXsize As Long dwYsize As Long dwXCountChars As Long dwYCountChars As Long dwFillAttribute As Long dwFlags As Long wShowWindow As Integer cbReserved2 As Integer lpReserved2 As Long hStdInput As Long hStdOutput As Long hStdError As Long End Type Declare Function CloseHandle Lib "kernel32" (hObject As Long) As Boolean Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hObject As Long, ByRef dwExitCode As Long) As Boolean Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long 'Public Sub ShellAndWait(AppToRun)As Integer Function ShellAndWait(AppToRun) As Integer Dim NameOfProc As PROCESS_INFORMATION Dim NameStart As STARTUPINFO Dim rc As Long Dim dwExitCode As Long dwExitCode = -1 ShellAndWait = dwExitCode NameStart.cb = Len(NameStart) rc = CreateProcessA(0&, AppToRun, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, NameStart, NameOfProc) rc = WaitForSingleObject(NameOfProc.hProcess, INFINITE) rc = GetExitCodeProcess(NameOfProc.hProcess, dwExitCode) MsgBox "ExitCode for the process is, dwExitCode = " & dwExitCode ShellAndWait = dwExitCode rc = CloseHandle(NameOfProc.hProcess) End Function

      E Offline
      E Offline
      Ernest Laurentin
      wrote on last edited by
      #2

      Try this (Need Script Host 5.5+):

      Sub ShellAndWait(AppToRun)
      Dim Shell
      Set Shell = CreateObject("WScript.Shell")
      Shell.Exec( AppToRun )
      End Sub

      YVOTD: 15 "The eyes of the Lord are on the righteous and his ears are attentive to their cry; 16 the face of the Lord is against those who do evil, to cut off the memory of them from the earth. " - Psalm 34:15-16 (1 Peter 3:11-12) (NIV)

      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