I have a web application written in C# that needs to display a message box using WSCRIPT.EXE (from C:\WINDOWS\SYSTEM32).
// Show the message in a Windows Script Message Box
ps.FileName = "wscript.exe";
ps.Arguments = string.Format("\"{0}\" \"{1}\"", strScriptName, strCleanedAlertMessage);
ps.CreateNoWindow = true;
Process.Start(ps);
This works as expected on my local PC, but does not work or error when running from our development web server.
We are running IIS 7 on a Windows Server 2008 R2.
Is this possible? Do I need to configure certain security setting son the web server?
Thanks!
Related
im creating a console application in C# to open and connect with my Windows Desktop Application, in my computer its working but when i installed it in the cliente idk why doesnt open the application, in some post i saw that if the console application its running in other monitor (what is the client case) gets error but we noticed that if the app iVMS-4200 (its a security camera software) is open the winAppDriver does not work.
//Appium Driver URL it works like a windows Service on your PC
string appiumDriverURI = "http://127.0.0.1:4723";
//Application Key of your UWA
//U can use any .Exe file as well for open a windows Application
string calApp = #"C:\Safesmart Plus\SmartCard.exe";
AppiumOptions opt = new AppiumOptions();
opt.AddAdditionalCapability("app", calApp);
opt.AddAdditionalCapability("deviceName", "SmartCard");
WindowsDriver<WindowsElement> calSession = new WindowsDriver<WindowsElement>(new Uri(appiumDriverURI), opt);
Retrieve Credentials from Windows Credentials Store problem using C# in ASP.net website under IIS I am using following code
Local machine and windows 10 IIS its working fine. but when i try to hosting in windows server 2012 R2 not working.
My code:
var cm = new Credential();
cm.Target = "targetname";
cm.Type = CredentialType.Generic;
if (!cm.Exists())
{
Console.WriteLine("cm is null");
}
cm.Load();
Console.WriteLine(cm.Password);
Console.WriteLine(cm.Username);
Above code running on windows server 2012 R under IIS. But above code is not able to retrieve username and password.(cm is null always) I used same code in my console application and works fine. Please let me know any special instruction need to follow.
You should switch "Load User Profile" parameter of IIS App Pool to true. Then your code should start working.
I am trying to print a document which is working fine in my Visual studio 2010 application but when i am publishing my project on IIS 7 then printing is not working and i cant see any error in the event viewer .
MyProcess = new Process();
MyProcess.StartInfo.CreateNoWindow = false;
MyProcess.StartInfo.Verb = "print";
MyProcess.StartInfo.FileName = destinationPath;
MyProcess.Start();
MyProcess.WaitForExit(10000);
MyProcess.Close();
When you're running in Visual Studio, you're running as a logged-in, interactive user.
When you're running in IIS, well, you're not any of the above.
The way this is normally done in a web application is to:
Display the document to the user in the browser
Print the document by using the 'window.print' function from JavaScript.
If anyone still cares for an answer..
I had the same problem, solution was to give IIS user access to use installed printers on the computer. When you print from IIS , you're logged in as a system default user who by default doesn't have proper printer access setup in the registry.You need to give printer access to the default system user by adding few entries in the registry. Just follow this tutorial like I did http://support.microsoft.com/?kbid=184291.
It will fix it.
If the printer is not installed on the server, nothing is going to happen.
If you're trying to print from ASP.NET code to a printer attached to the client computer it's never going to work. The server cannot get to and use any resources on the client computers.
2nd and important thing change to LoadUserProfile to true in IIS Application pool.
I currently have an application written in C# that adds a website to IIS7 on the current machine and it works perfectly, the code is as follows
var iisManager = new ServerManager();
var sites = iisManager.Sites;
var site = sites.Add("WebsiteName", "C:\Website", 80);
var application = site.Applications[0];
application.ApplicationPoolName = appPool;
iisManager.CommitChanges();
I have to create a version of this code that will add a website to IIS on a remote machine located on the same network. That code is as follows.
var iisManager= ServerManager.OpenRemote("machineName"); //I've also tried machines IP
var sites = iisManager.Sites["Default Web Site"];
var site = Sites.Applications.Add("WebsiteName", "C:\Website", 80);
site.ApplicationPoolName = appPool;
iisManager.CommitChanges();
When machineName is the machine executing the code, it adds the website to IIS. However when machineName is the remote machine, I get the following exception
Retrieving the COM class factory for remote component with CLSID {2B72138B-3F5E-4502-8052-803546CE3364} from "remote machine name" failed due to the following error: 80070005 "remote machine"
The exception occurs when executing
var iisManager= ServerManager.OpenRemote("machineName");
Before executing the above code I use impersonation to impersonate an Administrator.
I can remote into the machine and even create a file on the machine using C# code.
I assume there is an issue with permissions on the remote machine or it could be because it's a VM, I'm really not sure.
The code 80070005, is fairly general and represents restricted access but I don't understand why considering I am impersonating an Admin.
I am executing the code on a Windows 7 sp1 x64 machine and the remote VM is running Windows Server 2008 sp2 x64.
If anyone has any ideas how to fix this issue or another way to add a website to IIS on a remote machine, I'd love to hear them.
Thanks
First of all you run your visual studio as administrator and OFF windows firewall of server then see it will work for Remote server
I have one console application which list website binding in IIS
using (var directoryEntry = new DirectoryEntry("IIS://localhost/w3svc/" + GetWebSiteId())) {
var bindings = directoryEntry.Properties["ServerBindings"];
}
I call this console application from ASP.NET via process
var process = new Process {
StartInfo = new ProcessStartInfo {
FileName = "c:/app.exe",
Arguments = "check",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
Everything works fine on development machine under Widows 7 / IIS 7.5, but when i test on Windows 2012 / IIS 8 im getting "Access is denied" error.
Error log
"System.Runtime.InteropServices.COMException (0x80070005): Access is denied.
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsContainer()
at System.DirectoryServices.DirectoryEntries.ChildEnumerator..ctor(DirectoryEntry container)
at System.DirectoryServices.DirectoryEntries.GetEnumerator()
at IISSubdomainManagement.Program.GetWebSiteId()
at IISSubdomainManagement.Program.TotalBindings()
at IISSubdomainManagement.Program.Main(String[] args)"
p.s Application pool identity is "ApplicationPoolIdentity"
I forget to mention, my console app works fine on my server when I run it from CMD
You need to give permission to the IUSR account to access and execute C:\app.exe. This link should provide you with the necessary information to find the right account.
You have probably granted the permission to 'ApplicationPoolIdentity' rather than to the virtual account that actually corresponds to that Application Pool. Read through the Microsoft's description or search online for virtual identity IIS, etc.
On your development machine, you probably have some sort of Full Admin rights, so it is not as restricted.
If you still have problems after that, I would recommend replicating the error with a Process Monitor running, so you can see exactly what process is accessing which resource with which identity. However, I would recommend replicating the issue on your development machine rather than running Process Monitor on the production. It takes a little bit of learning to be able to run it efficiently.
In IIS 7/8 go Control Panel / Program And Features / Turn Windows features on or off, and check all items from: Web Managment Tools, (it's include: IIS Managment Service, II 6 Managment Compatibility)
This Solution worked for me ==>
http://blogs.msdn.com/b/jpsanders/archive/2009/05/13/iis-7-adsi-error-system-runtime-interopservices-comexception-0x80005000-unknown-error-0x80005000.aspx?CommentPosted=true#commentmessage