Executer un programme externe

Résolu
Steph115 Messages postés 163 Date d'inscription mercredi 22 octobre 2003 Statut Membre Dernière intervention 3 février 2012 - 23 juil. 2007 à 11:35
zuff Messages postés 79 Date d'inscription lundi 28 octobre 2002 Statut Membre Dernière intervention 21 octobre 2008 - 24 juil. 2007 à 09:59
Bonjour,

Est-il possible que le site web en ASP 2 (possibilité de le basculer en ASP3) en C# lance un programme externe sur le serveur avec les droits d'Administrateur ?

Merci pour vos réponses,

Nexus
Chaque problème a sa solution. S'il n'y a pas de solution c'est qu'il n'y a pas de problème.

5 réponses

cs_poppyto Messages postés 540 Date d'inscription dimanche 29 décembre 2002 Statut Modérateur Dernière intervention 13 mai 2011
23 juil. 2007 à 11:54
3
Steph115 Messages postés 163 Date d'inscription mercredi 22 octobre 2003 Statut Membre Dernière intervention 3 février 2012
23 juil. 2007 à 17:00
J'ai trouvé

System.Diagnostics.
Process
.Start(
"notepad"
);

Merci. ++ Nexus Chaque problème a sa solution. S'il n'y a pas de solution c'est qu'il n'y a pas de problème.
3
Steph115 Messages postés 163 Date d'inscription mercredi 22 octobre 2003 Statut Membre Dernière intervention 3 février 2012
23 juil. 2007 à 14:41
OK Merci de ton coup de main je viens de mettre la fonction en place.

Saurais tu comment je peux faire pour lancer un fichier .bat qui est sur la même machine ?

Merci. ++ Nexus Chaque problème a sa solution. S'il n'y a pas de solution c'est qu'il n'y a pas de problème.
0
Steph115 Messages postés 163 Date d'inscription mercredi 22 octobre 2003 Statut Membre Dernière intervention 3 février 2012
23 juil. 2007 à 15:29
En fouillant un peu j'ai trouvé ceci mais en VB et en C# apparement ca ne serait pas les bonne méthode

Set WSH = Server.CreateObject("WScript.Shell")
Commande = "sc"
Commande = "cmd /c " & Commande

WSH.Run Commande, 0, True
Set WSH = Nothing


Merci. ++ Nexus Chaque problème a sa solution. S'il n'y a pas de solution c'est qu'il n'y a pas de problème.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
zuff Messages postés 79 Date d'inscription lundi 28 octobre 2002 Statut Membre Dernière intervention 21 octobre 2008
24 juil. 2007 à 09:59
J'ai trouvé ce code qui me permet de lancer un fichier bat :

// Get the full file path

string strFilePath = Server.MapPath(
".") +
"\" + 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 = Server.MapPath(

".");

// 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 input

while (strm.Peek() != -1){

sIn.WriteLine(strm.ReadLine());

}

strm.Close();

// Exit CMD.EXE

string 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();
0
Rejoignez-nous