Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help in Building a Visual C++ EXE

Status
Not open for further replies.

tatin

MIS
Apr 14, 2004
29
LC
I am not a C++ programmer, I do my thing with VFP. However, I want to create an EXE in C++ that would run a VBscript ('install.vbs'). That script is meant to modify a registry before I run my program (in VFP). My program EXE is called from the script. I don't wish to have my user starting the program from a script that can easily be modified by a user. Hence, I would love to have the VBscript embedded in the C++ EXE, and not to exist as a file.

Also I need the EXE to associate itself with an icon.

I hve generated a blank Project in C++ with the AppWizard and have included my icon and VBscript files in the resource folder in the Project (C++). All I need is the code that would run the Script and associate the EXE with my icon.


Here is the WinMain module.

Code:
// Install.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// The code to run the Vbscript to appear below.

	

	return 0;
}

I don't know where the association with my icon file is being made
 
Hey, I did some searching and came with the following but it is not working. The 'install.vbs' is in the project. Yet it would not run. It works fine when run outside of the C++ program.

Here is the code in my C++ Wmain

Code:
// Install.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	
STARTUPINFO si;
PROCESS_INFORMATION pi;

// Execute the command with a call to the CreateProcess API call.
memset(&si,0,sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.wShowWindow = SW_SHOW;
CreateProcess(NULL,"install.vbs",NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);

	return 0;
}

What did I do wrong? I took this from some post...
I BUILD the project and run the EXE and nothing happened. I simplified the script to just one line that pops the Msgbox.


 
I am making some progress. I precursored the "install.vbs" with "cscript.exe" and it worked. The trouble is the windows black box comes along with the scripts results when I do the Execute EXE in C++. However, when I run the EXE from windows I just see a flash of a black box.

Well I still don't know how to the icon associated with my EXE
 
I used "wscript.exe" instead of "cscript.exe" and it worked. My only troubles are:

1. The install.vbs file is not 'baked' into the .EXE generated file.
2. I cannot find a way to associate an icon with the .EXE generated. It the old DOS .EXE icons.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top