/build/static/layout/Breadcrumb_cap_w.png

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.

0 Comments   [ + ] Show comments

Answers (3)

Posted by: plus2plus 14 years ago
Senior Yellow Belt
0
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!
Posted by: kkaminsk 14 years ago
9th Degree Black Belt
-1
You can turn off UAC to get UAC out of the way but I would not recommend it. To elevate the batch file there is no magic fix, you are going to have to pick an elevation mechanism that meets your needs and putting passwords inside of scripts is definately not recommended either.
Posted by: JessicaD 14 years ago
Senior Yellow Belt
-1
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ