送给用 EditPlus 或 Programmer's Notepad 等编辑器写代码的朋友!

翁和正
2023-12-01

  昨天特意写的一个集编译连接和运行为一体的一个脚本!

  只能编译 C/ C++ 代码, 当然前提是你得有编译系统!

/*
    * DocumentName: CompileAndLinker.js
    *   CreateDate: 2009-9-11
    *        Author: BlueMouse, [Lin], [Weipengyuan], [阿远]
    *          Note: 编译和连接运行和运行C或CPP代码
    *    CallFormat: CompileAndLinker.js "编译程序的路径", "连接程序的路径", "源文件所在的目录", "编译和连接后输出的目录", "连接后生成的可执行文件名", "连接开关", "头文件目录表", "库文件目录表"
    *  CallExample: cscript.exe CompileAndLinker.js "D:\Dev-Cpp\Bin\g++.exe" "D:\Dev-Cpp\Bin\g++.exe" "E:\Programs\Example" "E:\Programs\Example\Output" "MyProgram" "-mwindows" "D:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include|D:/Dev-Cpp/include/c++/3.4.2/backward|D:/Dev-Cpp/include/c++/3.4.2/mingw32|D:/Dev-Cpp/include/c++/3.4.2|D:/Dev-Cpp/include" "D:/Dev-Cpp/lib"
*/

var oWsh    = new ActiveXObject("WScript.Shell");
var oFso    = new ActiveXObject("Scripting.FileSystemObject");
var aArgs    = new Array();
var aSFiles    = new Array();
var aOFiles    = new Array();
var sTemp    = new String("");
var check    = 0;
var nIndex    = 0;
var nJndex    = 0;
var Re;
var oFile, oFolder, oFiles, oCP, oLP;
var aHeaders, aLibrars;

//----------------------------------------------------------------------------------------------------------
//    检查参数合法性
//----------------------------------------------------------------------------------------------------------

if(WScript.Arguments.length==8)
{
    try
    {
        sTemp    = WScript.Arguments(0);
        oFile    = oFso.GetFile(sTemp);
        oFile    = null;
        check++;
        aArgs["CompileBinPath"] = sTemp;

        sTemp    = WScript.Arguments(1);
        oFile    = oFso.GetFile(sTemp);
        oFile    = null;
        check++;
        aArgs["LinkerBinPath"] = sTemp;


        sTemp    = WScript.Arguments(2);
        oFolder    = oFso.GetFolder(sTemp);
        sTemp    = oFolder.Path + "\\";
        oFolder = null;
        check++;
        aArgs["SocureDir"] = sTemp;

        sTemp    = WScript.Arguments(3);
        oFolder    = oFso.GetFolder(sTemp);
        sTemp    = oFolder.Path + "\\";
        oFolder = null;
        check++;
        aArgs["OutputDir"] = sTemp;

        try
        {
            sTemp    = WScript.Arguments(4);
            if(sTemp.length<=0)
            {
                throw    "您所提供的目标程序文件名参数不正确,请提供正确的参数!";
            }
            else
            {
                Re    = /\./;
                if(sTemp.search(Re)<0)
                {
                    sTemp    += ".exe";                    
                }
                aArgs["ExecFileName"] = sTemp;
                check++;
            }
            

            sTemp    = WScript.Arguments(5);
            if(sTemp.length<=0)
            {
                throw    "您所提供的库参数不正确,请提供正确的参数!";
            }
            else
            {
                aArgs["LinkerSwitch"] = sTemp;
                check++;
            }
        }
        catch(ErrInfo)
        {
            WScript.Echo(ErrInfo);
        }

        sTemp        = WScript.Arguments(6);
        aHeaders    = sTemp.split("|");
        if(aHeaders.length>0)
        {
            for(nIndex=0;nIndex<aHeaders.length;nIndex++)
            {
                oFolder    = oFso.GetFolder(aHeaders[nIndex]);
                oFolder    = null;
            }
        }
        else
        {
            oFolder    = oFso.GetFolder(sTemp);
            oFolder    = null;
            aHeaders    = new Array();
            aHeaders[0]    = sTemp;
        }
        check++;

        sTemp        = WScript.Arguments(7);
        aLibrars    = sTemp.split("|");
        if(aLibrars.length>0)
        {
            for(nIndex=0;nIndex<aLibrars.length;nIndex++)
            {
                oFolder    = oFso.GetFolder(aLibrars[nIndex]);
                oFolder    = null;
            }
        }
        else
        {
            oFolder    = oFso.GetFolder(sTemp);
            oFolder    = null;
            aLibrars    = new Array();
            aLibrars[0]    = sTemp;
        }
        check++;

    }
    catch(ErrObj)
    {
        if(ErrObj.number==-2146828235)
        {
            if(check==0)
            {
                WScript.Echo("您所提供的编译程序路径 [ " + sTemp + " ] 不正确!,请提供正确的参数!");
            }
            else if(check==1)
            {
                WScript.Echo("您所提供的连接程序路径 [ " + sTemp + " ] 不正确!,请提供正确的参数!");
            }
        }
        else if(ErrObj.number==-2146828212)
        {
            if(check==2)
            {
                WScript.Echo("您所提供的源文件所目录 [ " + sTemp + " ] 不正确!,请提供正确的参数!");

profile.yahoo.com/6FUG3TSOMSITXJZMLMXVQ7KGGQ/
profile.yahoo.com/CJMWZL4ZNPWTZXPE4JCNYV3I54/
profile.yahoo.com/HS6YYCHMO7ID6OZV7NZ7L5FKSE/
profile.yahoo.com/3XGXYPZT3THKPVQ4TXQHCKHMXY/
profile.yahoo.com/GSNGQ2AINGGHGYHE4KY5MWXE2Y/
profile.yahoo.com/74RCKJTYJPA6NKLJI6KFMDNOUI/
profile.yahoo.com/WII2LSXESPSRKXWLMIKLHRGASQ/
profile.yahoo.com/JDVQEWPPQ66PUK47BZO7676MSE/
profile.yahoo.com/KQ73BQMAD42JLAW4TQYFPZHYME/
profile.yahoo.com/A3TBERS7KPAATC6M2MUDIEPPHE/
profile.yahoo.com/ME3RBTE7XV7H7OISWPBJBU4Q2A/
profile.yahoo.com/UUCTVBCHN5P3O22GSY2Y4LS3KM/
profile.yahoo.com/5DD42LIOWIVEC3C3LLVB4IR6L4/
profile.yahoo.com/YJTU4JNJCMGNSJA4BROIV5367E/
profile.yahoo.com/ACH7ALTJKXM3ZMTUH37TJMM4HU/
profile.yahoo.com/UNIRWHYVEDBUOUH7LWSM3KLCYI/
profile.yahoo.com/OLM6OCA6DCJW34V5RFQHB5S3U4/
profile.yahoo.com/5A3NBCAMAN5GHARA44FIPLAPE4/
profile.yahoo.com/IDZAQHNCQKXQU6267CN4AGOVMA/
profile.yahoo.com/FHMIPWZ5CQ2IGX3V2JGXSIWURU/
profile.yahoo.com/NF3376KORFLV5QWIEULSFTRLLQ/
profile.yahoo.com/VCZ2W47EE6V6GL7CYYXXYXR2NA/
profile.yahoo.com/KZ3GGY3HHEZ4O3Z73DS3KY7OAI/
profile.yahoo.com/JXCJSHKPCPVXBOQ7J534QFVINQ/
profile.yahoo.com/3EOKGCUUHMX22KIAI7GML5AUCI/
profile.yahoo.com/FUO6MOEDGUSYPEOIJUHQJPXU7U/
profile.yahoo.com/F6BNCL7UA4N2QU4VU7TQS4GMLE/
profile.yahoo.com/GKR4HD2WEEDOSAOEBLLVPT4BGM/
profile.yahoo.com/F4DSPOKAULYUURHT5Q2GHGRP74/
profile.yahoo.com/CAPYUDHYGK4T5OC376VAIQF6JU/
profile.yahoo.com/RL73T5NKKMIA5ATI4UOXVNYJCE/
profile.yahoo.com/PYFFJ2FNCM72O7GP7JSVLEHCTY/
profile.yahoo.com/YV4MGP3T7PLUT5Q66JR7B6NIBU/
profile.yahoo.com/Z6UG6LBRTTF7ADW4437WKUDXGU/
profile.yahoo.com/ZAWGBC2HZG3G5S5IBOVTVMNJ2A/
profile.yahoo.com/IEOM46P5K6FMQVAEFUL2735D6U/
profile.yahoo.com/JHLVQLSGI36ARJGGVCQOHYPDQI/
profile.yahoo.com/3YAUGQDSUIOIUNT7VJJTJYTJZE/
profile.yahoo.com/GEJCGLX3RSX3CFXZN7ZQ45V5RE/
profile.yahoo.com/SWFT4BQFW5YV652VO3AAR7GVY4/
profile.yahoo.com/QEWPERHSO5CGAZIW26TUPK7I3U/
profile.yahoo.com/JK26UMRCUXDVDMY6BYNVOOJYUE/
profile.yahoo.com/Y5YATSDLQWP2DY2ZRYUU3YVGP4/
profile.yahoo.com/WSRRX26XRWVJJTE5LU35MY5RLA/
profile.yahoo.com/CNA5EDOG7RO4LXDA5UBF3VGW2Y/
profile.yahoo.com/QRLN2PRXNB7CSDE6Q3766RUHVQ/
profile.yahoo.com/NYOIMY4DNKTLKEX2KA4XYNUWFA/
profile.yahoo.com/35IZIGSXVKERCC6RBFEBSSKKJ4/
profile.yahoo.com/VU6OYHDP5HAEJKYS5T3IALIALM/
profile.yahoo.com/J6NTXRNENOJ3TU47SYQ4PAHNOM/
profile.yahoo.com/Z5QEHIJUQ47BBSF4P3RQ6344DY/
profile.yahoo.com/VILU55D3NKY5NUXNOQC6H573LE/
profile.yahoo.com/3R63NVDVAF4EDRGYZA7BIVAONI/
profile.yahoo.com/EI2TDGGO55AFBU6XWSQPS7LYOA/
profile.yahoo.com/3EFNWKN37P2723HJW5LVKOPWBA/
profile.yahoo.com/MAXO4UZIPIWUTCND6ASAKUJYXM/
profile.yahoo.com/EZSBG26PW76LSBEVG3MZRG27XM/
profile.yahoo.com/YMK3J3VRN5LBUPYKV3NJHRPPHQ/
profile.yahoo.com/SVTB5BBL5ONCCFPJKAG4QJ44RM/
profile.yahoo.com/M5NIB6Q6BWRLYNRSVD2L2MNZJ4/
profile.yahoo.com/762NN2FKDNPQSVJLCMW6UJBHDI/
profile.yahoo.com/C6SLU4RABJPNBTKAEE6WAHJSQM/
profile.yahoo.com/7U43VP2ZEKEQ76S53UUNORXDMQ/
profile.yahoo.com/SU3FWXSQEFFU2YEY3PXWLIHBMQ/
profile.yahoo.com/JZ64JDPIYNDW7FVNMPXYNFQFKY/
profile.yahoo.com/FWBCGTP53CM7Z3SUZZS7GS3XX4/
profile.yahoo.com/EKNBCOQEFJBPFUPDUXCMXERD7E/
profile.yahoo.com/MGUXIKNVGJI62IHIEPB3MJ7HQU/
profile.yahoo.com/USMC6OT4BWG3YVZBGCOJKSWSHA/
profile.yahoo.com/VYKK4W6SLKVZXG5GCOPJQAP75U/
profile.yahoo.com/WMWS4L4MBNDU5NUPHBMKDY45QY/
profile.yahoo.com/PIS3KRCPGYH74IYX3MGQB5U6JM/
profile.yahoo.com/XF4NZ542TO7BS5MOGATNG3USVI/
profile.yahoo.com/UEM55PGXUN4MP4FECICJNORYPU/
profile.yahoo.com/4CVJTJ4ELRIV7X6HHZGRA4CR3Q/
profile.yahoo.com/WCBQZRW6U6XEZ3HBIOI3WIYFSQ/
profile.yahoo.com/RPHOWRTWXIVOHJDCHLZYIKR2WE/
profile.yahoo.com/X357ROFRNJNRYMZJMGEXNHTVWI/
profile.yahoo.com/5MOBSZ3CHMLO53CLEASO3EGQDY/
profile.yahoo.com/GCF4SSTXUX3RD24LTH54HIAOIE/
profile.yahoo.com/56UPEH6Z3QATUESZTB7CMTYTUQ/
profile.yahoo.com/OEOJYUVCVHBSKL74VIPNW4N5F4/
profile.yahoo.com/LFJP45USYC47T2DXSGZLUAJZYU/
profile.yahoo.com/VDX7NO4JA6DIG3I4PZTJ7EVV6U/
profile.yahoo.com/HKLGNUMAOIDKTMV3CDYGRJEXCA/
profile.yahoo.com/JTT74DDVUROQTMBCRLELTBAN7M/
profile.yahoo.com/L65HKC24BEMM74GDDQFHXP2A4M/
profile.yahoo.com/SLCNYRLUCPZR7BQPJ7XHWYHM5Q/
profile.yahoo.com/Q34AC6HMZ3REC5Q7ARCWZZQGRI/
profile.yahoo.com/4ALSGIV44UICTUOIY74NQT6IV4/
profile.yahoo.com/LDRKGLODVYLCCC5GBEQ7LVGULE/
profile.yahoo.com/OOMLENV3IGWPEZHTRQS3NDBDXM/
profile.yahoo.com/2YMAYSDEMMPJRRTC2W6SALQPCE/
profile.yahoo.com/TGY5XVMVNWVQUMKZRUHVY76OYY/
profile.yahoo.com/44DMJIDUXTTRDQ7ZNTV3RXAYRI/
profile.yahoo.com/UQ4IYBETUY5YXQXRERUE54P7EI/
profile.yahoo.com/RXNACSDGQGOZIR63XQLUBN4LFI/
profile.yahoo.com/KFUX4FW3GD4JRUQ4UV2XBDV7DU/
profile.yahoo.com/RKBV43WS3WPC3KIMJQ4IGTYQRQ/
profile.yahoo.com/BRSQ3P4ZBEFEPGWXECRPDOZ3WU/
profile.yahoo.com/O2GJWZX5WK45ALUQ77FPE5WSGA/
profile.yahoo.com/5A5WTCXH5XGOW3D4CJAAF6VB2M/
profile.yahoo.com/UVY3SDDUDNJNEDKFG45QZ6532M/
profile.yahoo.com/DMVBIHULCBR4OAFZWFALF6JRDA/
profile.yahoo.com/5BO466WFLLC25UJAYPLAWIHTFM/
profile.yahoo.com/UIVTAWNS6LXIE7JOJW5BW5DT2E/
profile.yahoo.com/ZCQXGQIPM53ZX6NGZAEW5DJKAA/
profile.yahoo.com/LOHZRZDG5F7JJLGLUN3MTPFZUU/
profile.yahoo.com/A3L7T52LXHCCSOWOJ6WFYW37QE/
profile.yahoo.com/J7MSLMKKAYAPLO5NDTMC4XIXYA/
profile.yahoo.com/LKTQ4EKICBLVXWYXTXUD3ASBVI/
profile.yahoo.com/LOR2BH4DF6WASERGGND6EBKPZM/
profile.yahoo.com/II3E7O5RQ7GZ7XPEYF2AJWDCQA/
profile.yahoo.com/DYDQM24RJSI3WSDDWGLGNCUK4A/
profile.yahoo.com/YKODTTBDER7IID6B4CJVYCTJWE/
profile.yahoo.com/UND4IWNLWFAYRJNKV5UATMUPBQ/
profile.yahoo.com/37HPFCZRAM6WF3UPOGJLK54O54/
profile.yahoo.com/4B62WGM4KZMJA4FHWNFGG2OBH4/
profile.yahoo.com/TMVRYKMFRYNPBAY5CILZS7722A/
profile.yahoo.com/MRCEISRAL4JHMPSPGGIGNOSC3M/
profile.yahoo.com/WZMZ7345NIHCMYZK2UUE2EFMYM/
profile.yahoo.com/BNQ33W6FUPMLVJJVK4XIYCSUIA/
profile.yahoo.com/KNOK4EDWXXTDLD4GBTMNCIQVIE/
profile.yahoo.com/VJA6FXHG6C6KATX53SC7OCPM6Q/
profile.yahoo.com/G6TN6WN6NIJYRSQUENJT7QCNVA/
profile.yahoo.com/KMD2WJYSQW7YRDTU5Q7HB3JHYQ/
profile.yahoo.com/ZSIZEEVM3ZJJ2V45EX7CC5522Y/
profile.yahoo.com/R7TQZRFG3BPDLPFNAGWL55FLDY/
profile.yahoo.com/YDL3WOIAXTUFAHI7LPT6TAYX34/
profile.yahoo.com/337ZFW6LOECP4X7LM3HY2MNLN4/
profile.yahoo.com/3QVEWKA4LKH3GB25ZNJHRDYI34/
profile.yahoo.com/5NDFYSLKXL6U4W7PLS63T63ZWY/
profile.yahoo.com/SMV54Y77QHXMLGAJZBFPIPSH24/
profile.yahoo.com/MUBWEHALLEHV4LR5O32GEZWAUE/
profile.yahoo.com/GQ32APIGQLJQVTSMC7XPJ6K47Q/
profile.yahoo.com/LQSUPOYMSOHDU6WQHK5HX3X6ZI/
profile.yahoo.com/3WUBNZCD7PUMCFUL7NKHZKAL3Y/
profile.yahoo.com/75TLCBFPSYFL2T42WPJ2NHTVRU/
profile.yahoo.com/IM7JPUX4OD2U6RCEDGN7QHQ74U/
profile.yahoo.com/VONWYO4GBGOQHJEC233TLVSHTE/
profile.yahoo.com/D5WP6VAWLFOHX5N7ECXCHCIBII/
profile.yahoo.com/YE6LROZT5FCB6NOYGEGL4MK3IU/
profile.yahoo.com/IBUIGON6CSXS3DTWJ2T7GIZR44/
profile.yahoo.com/VXA44ZSHTOFUJES4IBVMACL3MU/
profile.yahoo.com/SLVJ3TSMUL4AUVFQ7XPFIVRANA/
profile.yahoo.com/IB66CD5OSQ25D6HJYEBU7Q6JNU/
profile.yahoo.com/QNQKN6CV3NZHBJ6ZPSUDO3TMEM/
profile.yahoo.com/HO5HVR2TNKEHRV5HJFHHRTWMKA/
profile.yahoo.com/LJWJB6T5KNTTTLTN7SZQXKI2U4/
profile.yahoo.com/IK36FB3THEXIDK4S6YQOCRE3IY/
profile.yahoo.com/2SLY3CP3MOSHI7XB55GTFDVJH4/
profile.yahoo.com/IV7XJBLDKMB3UPJ4WGUYLPETQY/
profile.yahoo.com/KCHSQ4K7XBCD2RDVSI7DM7XJVU/
profile.yahoo.com/XGB6WOYS3CJ5EZXGXFRZIDKG6I/
profile.yahoo.com/BJ2YUMSQ742A37SZZAPHKNOYF4/
profile.yahoo.com/QBCMNI5UZ3L3XQ467ACEEXP2IY/
profile.yahoo.com/6ML4W232GAILTMTAKRULN32OQ4/
profile.yahoo.com/GYLZ5YBUWXK7VBIGIPQMXYEKHE/
profile.yahoo.com/YE355A7JS3CVE2XTZ6RRR5YTGU/
profile.yahoo.com/CL5FD4BWVR3HN46BCGPUUU4DLY/
profile.yahoo.com/N5K6PXKV3NOZLJEFNSSAGJEO5E/
profile.yahoo.com/YGLYTMUF5WGQIFL7NRWKADTDKM/
profile.yahoo.com/NHNQWTKUMFLEPFEZHZIKMJ5OZM/
profile.yahoo.com/MIZNEDMV62FSJDCCJYHNHD5Y4U/
profile.yahoo.com/3LKFYMWF33DWR4DCTIMNWKUGWY/
profile.yahoo.com/ABIJHVOWO7CUIOURWIGHPQ747U/
profile.yahoo.com/BTV5CWUM737QFZBUJ6K34AG4FI/
profile.yahoo.com/IL52HCONDNOWO25AEFMF3CHI4Y/
profile.yahoo.com/MPOTRKOJHWAEOS4KT2GY43SUSU/
profile.yahoo.com/NXEZDCEEGLIHFLJ3FRV6MZKILM/
profile.yahoo.com/WSPLRRSF7XB4EAHBNP3K4PMT54/
profile.yahoo.com/QQE7EKSOLFZRDSDKQHNTFKMLZU/
profile.yahoo.com/A7VZHQL6JEQVD7RZ3TFASQHYQQ/
profile.yahoo.com/PCTOLW55PAJ2IS76ELUCHMWB3A/
profile.yahoo.com/ESSVIGYULLRJBTNXLBONLZZTJI/
profile.yahoo.com/T73OV63XUR5DIH3HXPQJVUUR54/
profile.yahoo.com/WM5ACXPIWUXR3H7B5YB2C3DMKQ/
profile.yahoo.com/I5K2D3USGY6E6ZP6KQACPZ3VTQ/
profile.yahoo.com/ESRXM6P42GJPWJHWXABFSMGEPE/
profile.yahoo.com/UW5CPWKVHXD7NUNCNHAMK7HE3E/
profile.yahoo.com/7ZYAJKJVPXFVSRVUPAYV3Y4JVM/
profile.yahoo.com/VENORY56OMWF3B4CG252522POM/
profile.yahoo.com/MWYQNSPNKKXLTLPRGAS7SHBNF4/
profile.yahoo.com/REZJJWPT4L6WIFDOLTRI44EYTY/
profile.yahoo.com/WPJQ435V4M7JJ22GQLYXZUPNFA/
profile.yahoo.com/JD427N3F43RQ42IFWQULKLKGOE/
            }
            else if(check==3)
            {
                WScript.Echo("您所提供的输出目录 [ " + sTemp + " ] 不正确!,请提供正确的参数!");
            }
            else if(check==6)
            {
                WScript.Echo("您所提供的头文件目录表不正确!,请提供正确的目录!");
            }
            else if(check==7)
            {
                WScript.Echo("您所提供的库文件目录表不正确!,请提供正确的目录!");
            }
        }
        else
        {
            WScript.Echo("编译脚本在检测参数合法性时遇到不明的错误 [ " + ErrObj.number + " ],脚本将停止执行!");
        }
    }

    if(check==8)
    {
        //------------------------------------------------
        //    取得需要编译的源文件并生成其对应的编译目标文件名
        //------------------------------------------------
        oFolder = oFso.GetFolder(aArgs["SocureDir"]);
        oFiles    = new Enumerator(oFolder.files);
        nIndex    = 0;

        for(;!oFiles.atEnd();oFiles.moveNext())
        {
            sTemp    = oFiles.item().Path;
            if((sTemp.substr(sTemp.length-4,1)=="."&&sTemp.substr(sTemp.length-3,3)=="cpp")||(sTemp.substr(sTemp.length-2,1)=="."&&sTemp.substr(sTemp.length-1,1)=="c"))
            {
                aSFiles[nIndex] = sTemp;
                Re                = /\./;
                sTemp            = oFiles.item().Name;
                nCheck            = sTemp.search(Re);
                aOFiles[nIndex] = aArgs["OutputDir"] + sTemp.substr(0,nCheck+1)+"o";            
                nIndex++;
            }
        }
        oFiles    = null;
        oFolder    = null;

        //------------------------------------------------
        //    编译源文件
        //------------------------------------------------
        WScript.Echo("---------- Compile ----------\r");
        check = 8;

        for(nIndex=0;nIndex<aSFiles.length;nIndex++)
        {
            sTemp    = aArgs["CompileBinPath"];
            sTemp    += " -c \"" + aSFiles[nIndex] + "\"";
            sTemp    += " -o \"" + aOFiles[nIndex] + "\"";
            for(nJndex=0;nJndex<aHeaders.length;nJndex++)
            {
                sTemp    += " -I\"" + aHeaders[nJndex] + "\"";
            }

            oCP        = oWsh.Exec(sTemp);
            sTemp    = "";
            while(oCP.status!=1)
            {
                if(!oCP.StdErr.AtEndOfStream)
                {
                    sTemp += oCP.StdErr.Read(1);
                }
            }
            if(sTemp.length==0)
            {
                WScript.Echo(aSFiles[nIndex] + " Compilation successful!\r");
                check++;
            }
            else
            {
                WScript.Echo(sTemp);
            }
            oCP        = null;
        }

        //------------------------------------------------
        //    连接目标文件
        //------------------------------------------------
        if(check==8+aSFiles.length)
        {
            WScript.Echo("\r---------- Linker ----------\r");
            
            sTemp = "";
            for(nIndex=0;nIndex<aOFiles.length;nIndex++)
            {
                sTemp    += " \"" + aOFiles[nIndex] + "\"";
            }
            sTemp    = aArgs["LinkerBinPath"] + " " + sTemp + " -o \"" + aArgs["OutputDir"] + aArgs["ExecFileName"] + "\"";
            for(nJndex=0;nJndex<aLibrars.length;nJndex++)
            {
                sTemp    += " -L\"" + aLibrars[nJndex] + "\"";
            }
            sTemp    += " " + aArgs["LinkerSwitch"];

            oLP        = oWsh.Exec(sTemp);
            sTemp    = "";
            while(oLP.status!=1)
            {
                if(!oLP.StdErr.AtEndOfStream)
                {
                    sTemp += oLP.StdErr.Read(1);
                }
            }
            if(sTemp.length==0)
            {
                WScript.Echo(aArgs["OutputDir"] + aArgs["ExecFileName"] + " Createing successful!\r");
                check++;
            }
            else
            {
                WScript.Echo(sTemp);
            }
            oLP        = null;
        }
    }

    //------------------------------------------------
    //    运行新生成的程序
    //------------------------------------------------
    if(check==8+1+aSFiles.length)
    {
        if(oWsh.Popup("代码已经成功编译及连接,是否要运行新生成的程序?",10,"运行程序",4|32)==6)
        {
            WScript.Echo("\r---------- Run ----------\r");
            
            check = oWsh.Run("\"" + aArgs["OutputDir"] + aArgs["ExecFileName"] + "\"",5,true);

            WScript.Echo("RturenVal( " + check + " ) ");
        }
    }
}
else if(WScript.Arguments.length<8)
{
    WScript.Echo("您提供的参数数量不够,脚本将停止执行!");
}
else if(WScript.Arguments.length>8)
{
    WScript.Echo("您提供的参数数量过多,脚本将停止执行!");
}

//
// 结束脚本执行
//
oWsh    = null;
oFso    = null;
aArgs    = null;
WScript.Quit();

 类似资料: