mebob said:
Why don't you just use the Windows ShellExecute function? Check it out:
ShellExecute Function (Windows). And if you are just making this program to run a batch file, consider using a higher level language like C.
Here is my completed source code.
My program size is 16,384 bytes with 12,862 bytes that is used by the icon.
I think a comparable C program would be far larger.
; C_To_USB.asm Update files on thumbdrive
;
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\advapi32.inc
include \masm32\macros\macros.asm
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\advapi32.lib
CTEXT MACRO y:VARARG
LOCAL sym
CONST segment
IFIDNI <y>,<>
sym db 0
ELSE
sym db y,0
ENDIF
CONST ends
EXITM <OFFSET sym>
ENDM
IsWinNT PROTO
ReqNTPrivilege PROTO :DWORD
.DATA
AppName BYTE "C_2_USB", 0
No_Batch_File db "Batch file is not present.",0
Batch_File db "C:\Bat\J_Cruzer.bat",0
.data?
szComspec byte MAX_PATH dup(?)
szAppname byte MAX_PATH dup(?)
ProcessInfo PROCESS_INFORMATION<?>
StartupInfo STARTUPINFO<?>
.code
start:
; check if batch file is present
invoke GetFileAttributes,offset Batch_File
.IF EAX == 0FFFFFFFFh
invoke MessageBox, 0, ADDR No_Batch_File, ADDR AppName,MB_ICONINFORMATION
invoke ExitProcess,NULL
.ENDIF
invoke GetStartupInfo, addr StartupInfo
invoke GetEnvironmentVariable, CTEXT('ComSpec'), addr szComspec, sizeof szComspec
invoke wsprintf, addr szAppname, CTEXT('"%s" /c "c:\Bat\J_Cruzer.bat"'), addr szComspec
invoke CreateProcess, 0, addr szAppname, 0, 0, FALSE, \
NORMAL_PRIORITY_CLASS, 0, 0, addr StartupInfo, addr ProcessInfo
invoke WaitForSingleObject, ProcessInfo.hProcess, INFINITE
invoke ExitProcess,NULL
end start
rsrc.rc
#define APP_VERSION_INFO 1 // Define at the top your .RC file
// example version resource
APP_VERSION_INFO VERSIONINFO
FILEVERSION 1,0 //1,1,0,0
PRODUCTVERSION 1,0 //1,1,0,0
FILEFLAGSMASK 0x17L
FILEFLAGS 0x0L
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
{
BLOCK "StringFileInfo"
{
BLOCK "040904b0"
{
VALUE "CompanyName", "Siege_Works 2011"
VALUE "FileDescription", "Files to Usb Drive"
VALUE "FileVersion", "1.0"
VALUE "InternalName", "C_To_Usb.exe"
VALUE "LegalCopyright", "© QHR"
VALUE "OriginalFilename", "C_To_Usb.exe"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1200
}
}
200 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "Usb_Drive.ico"
Edited by dargueta, 27 January 2011 - 11:42 AM.
Dude, seriously - use code tags!