How can I execute exe file (which writes a txt file) in classic asp -
i want have server page executes exe file compiled based on c
the exe file filew.exe generated filew.c;
filew.c>
#include <stdio.h> int main () { file * fp; fp = fopen("test.txt" , "w"); char* teststr = "this test string"; fwrite(teststr , 1 , sizeof(teststr) , fp); fclose(fp); return 0; }
i've tried few methods accomplish this;
first tried run shellobject
dim shellobj set shellobj = server.createobject("wscript.shell") shellobj.run "e:\test\filew.exe" set shellobj = nothing
it didn't work.. tried this
dim shellobj shellobj = server.createobject("shell.application") shellobj.shellexecute "e:\test\filew.exe" set shellobj = nothing
still no... made batch file executes exe file
test.bat>
dir > e:\test\dir1.txt e:\test\filew.exe dir > e:\test\dir2.txt
// first , third line test whether batch file executed right or not
i called batch file by
dim shellobj set shellobj = server.createobject("wscript.shell") shellobj.run "e:\test\test.bat" set shellobj = nothing
the result was... dir1.txt , dir2.txt created no test.txt!!
function execstdout(cmd) dim gowsh : set gowsh = createobject( "wscript.shell" ) dim aret: set aret = gowsh.exec(cmd) execstdout = aret.stdout.readall() end function theoutput = execstdout("c:\runvirus.bat") response.write "the output " & theoutput
Comments
Post a Comment