La première chose vérifie que le WMI fonctionne correctement sur le serveur.
Ensuite le script que tu montre en exemple est du VBscript.
Voici le code que j'utilise sur mon serveur avec un fichier .bat qui lance mon programme qui génére des vignettes à partir de pdf :
System.IO.
FileStream fs = new System.IO.FileStream(LeChemin + "images" + Session["Login"].ToString() + ".bat", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);System.IO.
StreamWriter sw = new System.IO.StreamWriter(fs);string LigneBat = "nconvert -npcd 2 -size 256x256+0 -ctype grey -corder inter -out jpeg -o \"" + LeChemin + "Miniatures\\%.jpg\" -ratio -rtype lanczos -rflag orient -resize 160 120 -text_flag center -text_font \"Bodoni MT Black\" 15 -text_color 66 66 66 -text \"URBALYON\" \"" + path + nomFichier + "\"";sw.WriteLine(LigneBat);
sw.Flush();
sw.Close();
fs.Close();
// Get the full file pathstring strFilePath = LeChemin + "images" + Session["Login"].ToString() + ".bat";// Create the ProcessInfo objectSystem.Diagnostics.
ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("cmd.exe");psi.UseShellExecute =
false;psi.RedirectStandardOutput =
true;psi.RedirectStandardInput =
true;psi.RedirectStandardError =
true;psi.WorkingDirectory = LeChemin;
// Start the processSystem.Diagnostics.
Process proc = System.Diagnostics.Process.Start(psi);
// Open the batch file for readingSystem.IO.
StreamReader strm = System.IO.File.OpenText(strFilePath);// Attach the output for readingSystem.IO.
StreamReader sOut = proc.StandardOutput;// Attach the in for writingSystem.IO.
StreamWriter sIn = proc.StandardInput;
// Write each line of the batch file to standard inputwhile (strm.Peek() != -1){
sIn.WriteLine(strm.ReadLine());
}
strm.Close();
// Exit CMD.EXEstring stEchoFmt = "# {0} run successfully. Exiting";sIn.WriteLine(
String.Format(stEchoFmt, strFilePath));sIn.WriteLine(
"EXIT");// Close the processproc.Close();
// Read the sOut to a string.string results = sOut.ReadToEnd().Trim();
// Close the io Streams;sIn.Close();
sOut.Close();