Open a URL from windows service - windows

http://www.myserver.com/mypage.php?param1=abc&param2=123
I need to open this URL from a windows service either by IExplorer or without opening on windows startup.
OR
Can I submit an HTML form to my web server from a windows service on windows startup?

Depending on your requirements, the best way to do this might be by using HttpWebRequest. You can just write some code like this to accomplish the form post:
string url = "http://www.myserver.com/mypage.php?param1=abc&param2=123";
var request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "POST";
var response = (HttpWebResponse)request.GetResponse();
// etc... read the response from the server here, if you need it

On Windows Vista and later, services use a noninteractive window station and cannot interact with the user. Read here for more information.

Related

Windows - Get the URLs passed by the computer?

In Windows how to retrieve the URLs passed by the computer? I mean any URLs browsed by the web browsers. The reason is I have an installer which sends an HTTP POST via an URL to the web server. However I do not have the source code of the installer. How to get the URL passed by this installer?

How to send any data to my web page in a query string (Windows phone)?

I have a windows phone application and I need to send some information from my app to a web page that I have. I need to send some information from my app by querystring to the web page.
Any help / example of how I could do this?
Thank you!
To send data in form of key/value to your server, you can simply call a url as if you were downloading a string from a url. Just deliver your parameters in that url.
new System.Net.WebClient()
.DownloadStringAsync(new Uri("http://yourSite.com/saveValues.php?key1=value1&key2=value2"));
If you want to parse a feedback from your server, whether saving was successful or not, you can return this information as text and await the feedback from your server using the DownloadStringCompleted event from the webClient. Eighter way is not blocking your thread and the app will continue to run smooth.
You can try to use web client like this
parameter = new StringBuilder();
parameter.AppendFormat("{0}={1}", "name_of_your_parameter", HttpUtility.UrlEncode(value_to_send));
webClient = new WebClient();
webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
webClient.Headers[HttpRequestHeader.ContentLength] = parameter.Length.ToString();
webClient.UploadStringAsync(new Uri(your_url), "POST", parameter.ToString());
webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(your event handler);
this code will send your query string as POST method.

XMLHttpRequest issue with Windows Standard User

I have an HTML page with the following JS script on it. The script sends the request (in Firefox) when logged in as an Admin User but not as a Standard User:
var req = new XMLHttpRequest();
req.open("POST", "http://localhost:8400");
req.onreadystatechange = pingHandler;
req.send();
I have tried disabling the Windows Firewall with no luck. Any ideas what's blocking the request to go out?
It turned out that Firefox was not configured to allow mixed content (http request from within an https environment) for the Standard User. This change was made only for the Admin User, and it was incorrectly assumed that it was applied to all users.

How to control a cisco IP-Phone from the CLI?

I've a Cisco IP-Phone 7945 and I want to control it from my CLI. For example I want to start a command like
call start 12345 #12345 is the number I want to call
or
call cancel
Anybody knows a tool or something similiar?
I'm writing a rails app and I want to start a call from within the app after a certain action.
The 7945 has a web interface that permits execution of commands, including a "Dial" command, by authenticated users.
Your rails app would connect to the phone at http://phone-ip-address/CGI/Execute and POST some XML that looks like this:
<CiscoIPPhoneExecute>
<ExecuteItem URL="Dial:12345" />
</CiscoIPPhoneExecute>
The authentication is done with HTTP Basic Auth and the back-end authenticator is determined by what phone system your 7945 is connected to. If Cisco Call Manager, it uses the assigned Call Manager user information.
Look for the IP Phone Services guides on cisco.com for details. Quick links:
HTTP Requests and Header Settings
CiscoIPPhone XML Objects
Internal URI Features
Short answer: it's not a CLI but it is straightforward to program a dialer by interacting with the phone over HTTP.
I know this is an old thread, but thought I'd post this working code example in Ruby. Tested on the CP-8941 phone. Username & password schemes will vary. Our system is set up to interface to Active Directory, so the username and password are those of our Windows login.
require "net/http"
require "uri"
phone = "ip-of-your-phone"
user = "your-username-goes-here"
secret = "your-password-goes-here"
prefix = "91"
todial = "number-to-dial-goes-here"
uri = URI.parse("http://#{phone}/CGI/Execute")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
request.basic_auth(user, secret)
request.set_form_data({"XML" => %(<CiscoIPPhoneExecute><ExecuteItem URL="Dial:#{prefix}#{todial}" /></CiscoIPPhoneExecute>) })
response = http.request(request)

WP7 and Http-Referer

I've written an app that shows comments from Disqus and when I run it as a .NET application on my desktop it works great. It sends a http requst and then deserialize the json objects. But when I move the code to my Windows Phone app I get an error from Disqus.
It appears that because Windows Phone decides to add a random http referer my request fails. I'm not allowed to change the referer on the windows phone I get the message "The 'Referer' header cannot be modified directly." if I try to do that.
Is there a workaround for this that doesn't require me to build a proxy that removes the referer header?
From what I can gather from this post, there's no way to remove the Referer header without using a proxy service. Apparently this code worked for one person:
var uri = new Uri ("http://some.where");
var request = WebRequestCreator.ClientHttp.Create (uri) as HttpWebRequest;
request.Headers ["user-agent"] = "My user agent string";
request.BeginGetResponse (...);
However, it seems that the general consensus in that thread is that there's no way to change it, but it should be fixed in the Mango version.
Instead of request.Referer = referer use request.Headers[HttpRequestHeader.Referer] = referer and it will work

Resources