-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
58 lines (49 loc) · 2.17 KB
/
Copy pathProgram.cs
File metadata and controls
58 lines (49 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using System.IO;
using System.Diagnostics;
public class Program {
[STAThread]
public static void Main() {
string ipAddress = Interaction.InputBox(
"Enter the IP address or URL of the legacy device:",
"LegacyWebBox Connection",
"192.168.1.254"
);
if (string.IsNullOrWhiteSpace(ipAddress)) return;
if (!ipAddress.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
!ipAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) {
ipAddress = "http://" + ipAddress;
}
string vbs =
"Dim shell\r\n" +
"Set shell = CreateObject(\"WScript.Shell\")\r\n" +
"shell.RegWrite \"HKCU\\Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION\\iexplore.exe\", 8888, \"REG_DWORD\"\r\n" +
"shell.RegWrite \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Ext\\Settings\\{F5078F32-C551-11D3-89B9-0000F81FE221}\\Flags\", 0, \"REG_DWORD\"\r\n" +
"Dim ie\r\n" +
"Set ie = CreateObject(\"InternetExplorer.Application\")\r\n" +
"ie.Navigate \"" + ipAddress + "\"\r\n" +
"ie.Visible = True\r\n" +
"ie.ToolBar = True\r\n" +
"ie.MenuBar = False\r\n" +
"ie.StatusBar = False\r\n" +
"ie.Width = 1200\r\n" +
"ie.Height = 800\r\n";
string tmpPath = Path.Combine(Path.GetTempPath(), "legacywebbox_tmp.vbs");
try {
File.WriteAllText(tmpPath, vbs);
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "wscript.exe";
psi.Arguments = "\"" + tmpPath + "\"";
psi.UseShellExecute = false;
Process p = Process.Start(psi);
System.Threading.Thread.Sleep(2000);
try { File.Delete(tmpPath); } catch { }
} catch (Exception ex) {
MessageBox.Show("Error: " + ex.Message, "LegacyWebBox",
MessageBoxButtons.OK, MessageBoxIcon.Error);
try { File.Delete(tmpPath); } catch { }
}
}
}