How to Accessing .vbs file in Firefox and Chrome Browser Using Html - google-chrome

Am Calling Notepad.vbs File In IE Browser... It Works
The Notepad.vbs Contains
Dim obj
Set obj = WScript.CreateObject( "WScript.Shell" )
obj.Exec("notepad.exe")
Set obj = Nothing
How To Executing This Notepad.vbs In FireFox and Chrome Browser....?

CreateObject is ActiveX technology. It's supperted only in Internet Explorer.

Whatever browser we can run the vbs script file using ASP (Server Side Script)
(I.E.,):
<%
Dim obj
Set obj = WScript.CreateObject( "WScript.Shell" )
obj.Exec("notepad.exe")
Set obj = Nothing
%>

Related

C# Get full html document from site

I tried to use GetStringAsync
using (var client = new HttpClient())
{
var html = await client.GetStringAsync(url);
richTextBox1.Text = html.ToString();
}
and DownloadString
System.Net.WebClient wc = new System.Net.WebClient();
string webData = wc.DownloadString(url);
richTextBox1.Text = webData;
But it doesn't give me full html document like Google Chrome F12. How can I get full html code of url using C#?
Need this url: http://poeplanner.com/ but it doesn't show me even a single table when Chrome F12 does.
My guess is that the code you don't see is a code that added with javascript. So you need use a browser program to get this code too.
This app will run the javascript too and you can ask from it the final html.
If I'm right, try to use phantomjs.
Related question on PhantomJS

Convert xlsx file to HTML with VBscript or batch script

I've researched for days but I can not find anything to resolve this issue that I am having.
I have an excel file in .xlsx format that is updated through out the day. What I need to do is call a batch that converts it to .html. I will be taking that HTML file and copying it to a folder that automatically publishes it for internal uses at my company.
If anyone out there can help it would be greatly appreciated.
Excel lets you save as a web page natively. It also has a "single file" web page that combines all images/etc into a single file. It uses the mht or mhtml extension.
Const xlHtml = 44
Const xlWebArchive = 45
' Create an instance of Excel and open the workbook...
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open "C:\Folder\MyWorkbook.xlsx"
' Save the workbook as an HTML or MHTML page...
objExcel.ActiveWorkbook.SaveAs "C:\Folder\MyPage.html", xlHtml
' -or-
objExcel.ActiveWorkbook.SaveAs "C:\Folder\MyPage.mhtml", xlWebArchive
' Close Excel...
objExcel.Quit
If Some one looking for C#
Add Reference -> COM -> Look for Microsoft Excel, Microsoft Office then
using Excel = Microsoft.Office.Interop.Excel;
namespace ExcelToSinglePageWeb
{
class Program
{
static void Main(string[] args)
{
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(#"C:\Users\name\Desktop\Work In Progress.xlsx");
xlWorkbook.SaveAs(#"C:\Users\name\Desktop\SomePage.mhtml", 45);
xlApp.Quit();
}
}
}

Chrome: Possible to script like InternetExplorer.Application in VBScript?

I have a VBScript that uses InternetExplorer.Application to login to a website, then refresh the page every once in a while to keep the website from logging out due to inactivity. This sits on a dashboard screen mounted in our office. Is there a way to script Chrome in a similar way? It doesn't have to be VBScript, any language will do. We are looking to stop using Internet Explorer.
You can't control Google Chrome as an object in VBscript. Here's why: VBScript CreateObject Google Chrome
That being said, you CAN still manipulate a refresh on google chrome. Just copy the title of the page you want refreshing, and once the page has been activated, use a SendKeys command to cause it to refresh. e.g.(CTRL+R) - causes refresh, or in Sendkeys ("^r").
Once you've got it refreshing, just set it in a loop and set your wait period for however long you want.
'This is an infinite loop, only disposed of by exiting Wscript.exe or Cscript.exe
Do While(true)
Dim PageTitleToRefresh, IntervalinSeconds, x, objShell, Success
'Page Titles - NOT the page address - (google.com = NO) (Google = YES)
'Page Titles are normally stored at the top of the browser or in the tab name of the browser.
PageTitleToRefresh = "Google"
IntervalinSeconds = 10
x = IntervalinSeconds * 1000
Set objShell = WScript.CreateObject("WScript.Shell")
Do Until Success = True
Success = objShell.AppActivate(PageTitleToRefresh)
Wscript.Sleep 1000
Loop
wscript.echo "Activated, now refreshing"
objShell.SendKeys "^r"
Wscript.Sleep IntervalinSeconds
Loop
here is a way that I edited in js file, but can be also realized in vbs :
var fso = new ActiveXObject("Scripting.FileSystemObject");
var chrome = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
var url = 'http://google.com';
if (fso.FileExists(chrome)){
var objShell = WScript.CreateObject("Shell.Application");
objShell.ShellExecute(chrome, "--app="+url, "", "", 1);
}
else{ //if chrome doesn''t exists, so launch ie :
oIE1 = WScript.CreateObject ("InternetExplorer.Application");
oIE1.Visible = 1;
oIE1.AddressBar = 0;
oIE1.StatusBar = 0;
oIE1.ToolBar = 0;
oIE1.MenuBar = 0;
oIE1.Navigate(url);
}

Open local file in System.Windows.Forms.WebBrowser control

I am rendering the following simple HTML in a Windows Forms WebBrowser control:
<HTML>
<HEAD></HEAD>
<BODY bottommargin='0' leftmargin='10' rightmargin='0' topmargin='10'>
<span>Programs</span><br /><br />
<a href='file:///C:\Temp\prog1.cnc'>Program 1</a><br />
<a href='file:///C:\Temp\prog2.cnc'>Program 2</a><br />
<a href='file:///C:\Temp\prog3.cnc'>Program 3</a><br />
</BODY>
</HTML>
The issue is that the links do not navigate to the file identified in the href attribute.
I can confirm that the AllowNavigation property on the control is set to True.
Also, the Navigating event does not fire when I click the links.
If I change the paths to reference a file on a remote share, everything works as expected, for example:
<a href='file://\\servername\Temp\prog1.cnc'>Program 1</a>
OR without the file prefix:
<a href='\\servername\Temp\prog1.cnc'>Program 1</a>
Both fire the Navigating event.
What am I missing when referencing a local file?
I have tried changing the file path to a public folder to rule out permission issues.
The same app is also writing the files so permission issues seem unlikely.
The files are simple text files which I'm trying to display in the browser control when the links are clicked.
Code setting the DocumentText Property of the browser control:
Private Shared Function LoadProgramHtml(ByVal programFiles() As String) As String
Dim programHtml As New StringBuilder
If ProgramFiles.Length > 0 Then
programHtml.AppendLine("<HTML>")
programHtml.AppendLine("<HEAD></HEAD>")
programHtml.AppendLine("<BODY bottommargin='0' leftmargin='10' rightmargin='0' topmargin='10'>")
programHtml.AppendLine("<span>Programs</span><br /><br />")
For Each program As String In ProgramFiles
Dim progInfo As New FileInfo(program)
programHtml.AppendLine(String.Format("<a href='file://{0}'>{1}</a><br />", progInfo.FullName, progInfo.Name.ToUpper))
Next
programHtml.AppendLine("</BODY>")
programHtml.AppendLine("</HTML>")
End If
WebViewer.DocumentText = programHtml.ToString()
End Function
Code to handle the navigating event:
Private Sub WebViewer_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebViewer.Navigating
Dim filepath As String = e.Url.OriginalString
If File.Exists(filepath) Then
Dim progInfo As New FileInfo(filepath)
If progInfo.Extension.ToLower = ".cnc" Then
WebViewer.ScrollBarsEnabled = True
WebViewer.DocumentText = File.ReadAllText(e.Url.OriginalString).Replace(Chr(13), "<br />")
End If
e.Cancel = True
End If
End Sub
I have found a work around which will keep me going for the time being but I would still be interested if anyone has an explanation for the behaviour described.
By faking a remote file path, I can cause the Navigating event to fire as it did for actual remote files, then in the Navigating event, I re-write the path to re-reference the local file as follows:
Setting Document Text
Change:
programHtml.AppendLine(String.Format("<a href='file://{0}'>{1}</a><br />", progInfo.FullName, progInfo.Name.ToUpper))
To:
programHtml.AppendLine(String.Format("<a href='{0}' target='_top'>{1}</a><br />", progInfo.FullName.ToLower.Replace("c:", "\\faked"), progInfo.Name.ToUpper))
'note the `\\faked`
Handling the Navigating event
Add the following:
Dim filepath As String = e.Url.OriginalString.Replace("\\faked", "c:")
If File.Exists(filepath) Then
....

How to access downloaded sound in IsolatedStorage via URI (WP8)?

I am struggling with this problem of accessing the sound file (mp3) download in isolated storage to be used in Alarm ,
The problem mentioned before
I am getting this error:
BNS Error: The action request's sound uri is invalid
Please help me but remember I am using the sound file for Alarm
Regarding the code it is the same as the link above.
This is download and save code of the sound file :
Public Async Function DownloadFile(url As Uri) As Task(Of Stream)
wc = New WebClient()
AddHandler wc.OpenReadCompleted, AddressOf OpenReadCompleted
AddHandler wc.DownloadProgressChanged, AddressOf DownloadProgress
wc.OpenReadAsync(url)
Dim r As IO.Stream = Await tcs.Task
Return r
End Function
Private Sub OpenReadCompleted(sender As Object, e As OpenReadCompletedEventArgs)
If e.[Error] IsNot Nothing Then
tcs.TrySetException(e.[Error])
ElseIf e.Cancelled Then
tcs.TrySetCanceled()
Else
tcs.TrySetResult(e.Result)
Dim file As IsolatedStorageFile
file = IsolatedStorageFile.GetUserStoreForApplication()
Using Stream As IsolatedStorageFileStream = New IsolatedStorageFileStream("Sound.mp3", System.IO.FileMode.Create, file)
Dim buffer As Byte() = New Byte(1023) {}
While (e.Result.Read(buffer, 0, buffer.Length) > 0)
Stream.Write(buffer, 0, buffer.Length)
End While
End Using
End If
End Sub
Private Sub DownloadProgress(sender As Object, e As DownloadProgressChangedEventArgs)
Proind.Value = e.ProgressPercentage / 100
Proind.Text = e.ProgressPercentage.ToString & " %" & " ( " & (e.BytesReceived \ 1000).ToString & "/" & (e.TotalBytesToReceive \ 1000).ToString & " ) KB"
End Sub
The problem is that you are trying to set a file in the isolated storage as the sound of the alarm, and that's not allowed. Only files packaged in .xap can be set as sound source of the alarm:
Remarks
The Sound URI must point to a file packaged in the application’s .xap
file. Isolated storage is not supported. When the alarm is launched,
the sound is played quietly and then gradually increases in volume.
There is no way to modify this behavior.
From:
Alarm.Sound Property
However, there is a way you could use a downloaded song as alam's sound. In OpenReadCompleted method, instead of saving the downloaded file in the isolated storage, create a file using File.Create method, and store the data there. Then it will be possible to use this file as the alarm sound:
Here is the C# code, I think you will easily translate to VB:
byte[] buffer = new byte[e.Result.Length];
e.Result.Read(buffer, 0, buffer.Length);
using (var fs = File.Create("file.mp3"))
{
fs.Write(buffer, 0, buffer.Length);
}
Then, you can set the Sound property of the alarm as:
alarm.Sound = new Uri("/file.mp3", UriKind.Relative);