App-v on win7
Hi!
does anyone knows, how could i give permissions to package that calls bat file, because under limited user it calls, but it dont works, and also if i launch like user with admin rights it popups black window and ask yes or no to change setting, so i should take that off some how too.
does anyone knows, how could i give permissions to package that calls bat file, because under limited user it calls, but it dont works, and also if i launch like user with admin rights it popups black window and ask yes or no to change setting, so i should take that off some how too.
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
plus2plus
14 years ago
Okay, running .BAT files from ASP.NET using the System.Diagnostics.Process object and static methods this should be easy, right? Well, this might work for you, but it certainly won't work on my machines. And after doing lots of reasearh on the issue, it seems that other people are also having problems with this too. I wrestled with permissions and all sorts of other stuff, trying to get a simple batch file to run, with no luck. I tried lauching the bat file directly, launching cmd.exe and calling the bat file using stin. No dice. It seems that something on my machine was keeping an unattended process from running bat files. This makes sense, but I was never able to pinpoint what was preventing this, so I came up with a workaround. I realized that since I could sucessfully run cmd.exe, and send commands to it via stin, I could just open the batch file, and send each line to cmd.exe, which is essentially the same as running a batch file itself. This technique works great, and I thought I'd pass along the code here. // Get the full file path
string strFilePath = “c:\\temp\\test.batâ€Â; // Create the ProcessInfo object
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("cmd.exe");
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardError = true;
psi.WorkingDirectory = “c:\\temp\\“; // Start the process
System.Diagnostics.Process proc = System.Diagnostics.Process.Start(psi); // Open the batch file for reading
System.IO.StreamReader strm = System.IO.File.OpenText(strFilePath); // Attach the output for reading
System.IO.StreamReader sOut = proc.StandardOutput; // Attach the in for writing
System.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 process
proc.Close(); // Read the sOut to a string.
string results = sOut.ReadToEnd().Trim(); // Close the io Streams;
sIn.Close();
sOut.Close(); // Write out the results.
string fmtStdOut = "<font face=courier size=0>{0}</font>";
this.Response.Write(String.Format(fmtStdOut,results.Replace(System.Environment.NewLine, "<br>"))); That's it! Works like a charm!
string
psi.UseShellExecute =
psi.RedirectStandardOutput =
psi.RedirectStandardInput =
psi.RedirectStandardError =
psi.WorkingDirectory = “c:\\temp\\“;
while
{
sIn.WriteLine(strm.ReadLine());
}
string
sIn.WriteLine("EXIT");
string
sOut.Close();
string
Posted by:
kkaminsk
14 years ago
Posted by:
JessicaD
14 years ago
Landselots,
Microsoft does have an official Windows 7 Support Forum located here http://social.technet.microsoft.com/Forums/en-US/category/w7itpro/ . It is supported by product specialists as well as engineers and support teams. You may want to also check the threads available there for additional assistance and guidance.
Jessica
Microsoft Windows Client Team
Microsoft does have an official Windows 7 Support Forum located here http://social.technet.microsoft.com/Forums/en-US/category/w7itpro/ . It is supported by product specialists as well as engineers and support teams. You may want to also check the threads available there for additional assistance and guidance.
Jessica
Microsoft Windows Client Team
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.