Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 28th, 2007, 05:19 PM
Authorized User
 
Join Date: Jun 2003
Location: Aalst, Vlaanderen, Belgium.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Translating VBScript in VB

Hi,

Was wondering if it is easy to 'migrate' VBScript code to VB? Currently I have written an automatic installation procedure (like install SQL, then Java, then Office etc) in VBScript. This works fine and I'm using an IE explorer window to display the progress. However, since the script is critical and there isn't that much you can do with the IE page container, I was planning to do this in VB (form control is a lot better). But since I'm not that experienced in VB, I already ran in the following:

Where e.g. the Script uses (from WScript.Shell):
Shell.Run "notepad.exe", 0, True
VB instead uses Shell "notepad.exe" but without that many parameters where True states the script waits for execution until the application is out of the computer's memory.

It annoys me that this looks all very straightforward, but the syntax and logic (VBScript for procedures vs VB for logicc) is just so different.

So what I want to do is:

1. Display a form
2. Put on a label "Installing MS Office" while using the installation parameters in silent mode.
3. Once office is installed, put on a new label "Installing Java" while using parameters in silent mode.
4. and so on ..

So the form only has the purpose to display the installation progress.

Or should I just forget about it.

Your help is appreciated.

Sebastiaan.
Reply With Quote
  #2 (permalink)  
Old June 28th, 2007, 06:14 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I don't think you should forget about it. It is going to be a little tougher, to be sure, but you're going to like the results. And it will be stable, easily modifiable, and so on.

I think you are going to want to use CreateProcess and WaitForSingleObject APIs.

You'll have to search around a little for more details, but the brief looking I have just done myself turned up
Code:
  if(CreateProcess("c:\\winnt\\notepad.exe", NULL, 
      NULL,NULL,FALSE,0,NULL,
      NULL,&StartupInfo,&ProcessInfo))
  { 
      WaitForSingleObject(ProcessInfo.hProcess,INFINITE);
      CloseHandle(ProcessInfo.hThread);
      CloseHandle(ProcessInfo.hProcess);
  }  
  else
  {
      MessageBox("The process could not be started...");
  }
  Translated to VB this should be like
Code:
    Dim ProcessInf As ProcInfoType  ' I'm not sure the parts of this type
Code:
    Dim StartUpInf As StrtInfoType  ' I'm not sure the parts of this type

    If CreateProcess("""c:\winnt\notepad.exe""", , , , False, 0, , , _
                     StartUpInf, ProcessInf)

        ' Fill in your form here;  the process started.
        WaitForSingleObject(ProcessInfo.hProcess,INFINITE);
        CloseHandle(ProcessInfo.hThread);
        CloseHandle(ProcessInfo.hProcess);

    Else

        MsgBox "The process could not be started..."

    End If
    You will need to declare the types and the three API routines CreateProcess(), WaitForSingleObject() and CloseHandle().
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Translating WorkSheet Formula in VBA AndyL Beginning VB 6 2 June 11th, 2008 04:13 AM
translating XML into CSV file vxc2222 XSLT 1 December 29th, 2007 12:01 PM
Translating si function to HTML mcw22 Javascript How-To 1 October 27th, 2007 09:43 AM
Translating symbols to their unicode values Pankaj C XSLT 24 September 11th, 2007 03:35 AM
Translating graphics to text faridahhani Pro PHP 1 July 2nd, 2003 02:37 PM



All times are GMT -4. The time now is 12:16 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.