when i am running my script in compatibility mode i am getting following error? - internet-explorer-10

i want to automate the automatic web login this code work with ie9 and for some of the forms(which are developed by using form tag) fine.but when i run same script for the form which is build with tag table it is not taking id's in Ie10, windows8 but the same script take ids with IE9 windows7 but in my work environment now we have mostly windows8 machines. So i came to know to if we run in compatibility mode we can solve issue when i added code for running in compatibility mode i am getting this error . i don't understand what to do..
#include <IE.au3>
#include <GuiButton.au3>
#include <File.au3>
#RequireAdmin
If IsAdmin() then
$64Bit = ""
If #OSArch = "X64" Then
$64Bit = "64"
EndIf
If StringLeft(RegRead("HKLM" & $64Bit & "\SOFTWARE\Microsoft\Internet Explorer\Version Vector", "IE"), 1) > 8 Then ;Check for version 9 or later
$wshNetwork = ObjCreate("WScript.Network")
$struser = $wshNetwork.Username
$objWMIService = ObjGet("winmgmts:\\.\root\cimv2")
$objAcc = $objWMIService.Get('Win32_UserAccount.Name="' & $struser & '",Domain="' & #ComputerName & '"')
$objAccount = $objAcc.SID
RegWrite("HKU" & $64Bit & "\" & $objAccount & "\Software\Microsoft\Internet Explorer\BrowserEmulation\", "AllSitesCompatibilityMode", "REG_DWORD", 1)
RegWrite("HKU\" & $objAccount & "\Software\Microsoft\Internet Explorer\BrowserEmulation\", "AllSitesCompatibilityMode", "REG_DWORD", 1)
EndIf
EndIf
$url = "https://190.198.14.15/"
$formID = ""
$formUID = "username"
$uName = "admin"
$formPID = "password"
$pwd = "SeR^ER#iL0"
$formSubmit = "ID_LOGON"
;Launch the Internet Explorer as a private session
ShellExecute ("iexplore.exe", " -private about:blank", #programFilesDir & "\Internet Explorer\iexplore.exe", "open", #SW_MAXIMIZE)
WinWait ("Blank Page")
$oIE = _IEAttach ("about:blank", "url")
;Wait for the IE to launch
_IELoadWait ($oIE)
;Navigate to the given URL
_IENavigate ($oIE, $url)
;Get the IE process id specific to this instance
Local $PID = WinGetProcess(_IEPropertyGet($oIE, "hwnd"))
;Print the PID in the console
If $PID Then
;MsgBox(0, "Example", "Internet Explorer is running.")
;MsgBox(0,"Process ID",$PID)
ConsoleWrite("["&$PID&"]")
Else
MsgBox(0, "Example", "Unable to get the process id of IE instance")
EndIf
;Disable IE address bar and menu bar
_IEPropertySet ($oIE, "addressbar", False)
_IEPropertySet ($oIE, "menubar", False)
;Click on 'Continue to this website' option if there is any HTTPS certificate Warning
while(_IELinkClickByText ($oIE, "Continue to this website (not recommended)."))
_IELoadWait ($oIE,10000)
wend
;Get the field id and fill with provided value
;$oIE.document.getElementById($formUID).value = $uName
$oIE.document.getElementsByName($formUID).Item(0).value = $uName
$oIE.document.getElementById($formPID).value = $pwd
;$oSubmit = _IEGetObjByName ($oIE, $formSubmit)
$oSubmit = $oIE.document.getElementById($formSubmit)
_IEAction ($oSubmit, "click")
when i am running this i am getting an error :
>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\My_Files\Automation scripts\My tests\AutomaticWebpageLogin -1.au3"
"D:\My_Files\Automation scripts\My tests\AutomaticWebpageLogin -1.au3" (18) : ==> Variable must be of type "Object".:
$objAccount = $objAcc.SID
$objAccount = $objAcc^ ERROR
>Exit code: 1 Time: 0.697

An Error occured at your Authentification process (line of $objAcc =), maybe wrong password or username.
Maybe if an error occures, the .Get Function of the WMI Service don't returns an object.
Check for Errors like this
if(#error <> 0) Then
; ERROR HANDLER
EndIf
And check if the account informations are correct.
Look at your other question
Reference to Win32_UserAccount

Related

Milestone Camera Selector Software

I'm trying to create some AutoIT code for work to make launching our camera systems a bit easier. As of right now, I've been able to get my code to launch a gui, display a list of camera servers that you can add onto, and be able to add new servers to an internal directory. What I'm having a bit of trouble with is the section in which the program is supposed to switch to the newly launched Milestone software, type in the information, and click enter. I've found that the issue is linked to part of the start() function, in which WinWaitActive($handle) either isn't using the correct handle, or maybe the function I'm using is incorrect?
My end goal is to be able to wait 4 seconds, switch focus from whatever current window is selected to the newly opened Milestone window using either its handle or its PID, then send 2 TABs, the ip address, then send ENTER
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <ComboConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>
#Region EDIT THE BELOW INFORMATION-------------------------------------------------------------------------------------------------------------------------------------------
Local Const $milestone = "C:\Program Files\Milestone\XProtect Smart Client\Client.exe" ;Path to software
Local $Title = "Milestone Camera Selector"
#EndRegion-------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Region Script---------------------------------------------------------------------------------------------------------------------------------------------------------------
Local $iFileExists = FileExists($milestone) ;Check if the file exists, returns a 1 or 0
Global $list = IniReadSection(#TempDir & "\" & $Title & "\config.ini","Server") ;Read the ini file, this builds a 2D Array [X][0] is the key [X][1] is the value
HotKeySet("{F1}", "help")
If $iFileExists Then ;If FileExists = 1 (exists) then
If Not FileExists(#TempDir & "\" & $Title) Then ;If config directory does not exists then
Do
DirCreate(#TempDir & "\" & $Title) ;Create a directory in TempDir for the config.ini file to be stored locally
Until FileExists(#TempDir & "\" & $Title)
IniWrite(#TempDir & "\" & $Title & "\config.ini", "Server", "", "")
EndIf
Local $GUI = GUICreate($Title, 267, 115) ;Create the GUI
$start = GUICtrlCreateButton("Start", 40, 72, 65, 25) ;Create a button
$create = GUICtrlCreateButton("Add Server", 160, 72, 65, 25)
$server = GUICtrlCreateCombo("Select Server", 8, 8, 249, 25, $CBS_DROPDOWN) ;Create the combo box
For $i = 1 To UBound($list) - 1 ;Populate combo box with first value (name) from array
If $list[$i][0] <> "" Then GUICtrlSetData($server, $list[$i][0]) ;Ensure array is not empty and fill combox with KEYS
Next
$servername = GUICtrlCreateInput("Server Name", 8, 40, 121, 21)
GUICtrlSetState(-1, $GUI_HIDE)
$serverip = GUICtrlCreateInput("IP Address", 136, 40, 121, 21)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(#SW_SHOW)
While 1 ;Enter loop until user closes or presses button
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE ;Exit when closed
Exit
Case $start ;Store selection into variable, delete the GUI, and run the start function
$selection = GUICtrlRead($server)
If $selection <> "Select Server" Then
GUIDelete()
start()
EndIf
Case $create
If GUICtrlRead($create) = "Add Server" Then
GUICtrlSetState($servername, $GUI_SHOW)
GUICtrlSetState($serverip, $GUI_SHOW)
GUICtrlSetData($create, "Create")
Else
If (GUICtrlRead($servername) <> "" And GUICtrlRead($servername) <> "Server Name" And GUICtrlRead($serverip) <> "" And GUICtrlRead($serverip) <> "IP Address") Then
IniWrite(#TempDir & "\" & $Title & "\config.ini", "Server", GUICtrlRead($servername), GUICtrlRead($serverip))
GUICtrlSetState($servername, $GUI_HIDE)
GUICtrlSetState($serverip, $GUI_HIDE)
GUICtrlSetData($create, "Add Server")
Else
MsgBox($MB_ICONINFORMATION, $Title, "Invalid Server Name and IP Address.")
EndIf
For $i = UBound($list) - 1 To 0 Step -1
_GUICtrlComboBox_DeleteString($server, $i)
Next
Local $list = IniReadSection(#TempDir & "\" & $Title & "\config.ini","Server")
For $i = 1 To UBound($list) - 1
If $list[$i][0] <> "" Then GUICtrlSetData($server, $list[$i][0])
Next
EndIf
EndSwitch
WEnd
Else ;otherwise, message
MsgBox($MB_SYSTEMMODAL, "", "Milestone XProtect wasn't found on this computer" & #CRLF)
EndIf
Func start()
$iPID = Run($milestone,"", #SW_SHOWNOACTIVATE) ;Runs the software and returns the Process ID
Sleep(4000) ;sleep for 4 seconds
If #error Then MsgBox(0, $Title, "The program could not launch.") ;If Run returns a 0 or error, there was a problem
$handle = _GetHandleFromPID($iPID) ;Retrieve the handle of the program ran, jump to the function below
If $handle = 0 Then MsgBox(0, $Title, "The handle could not be found.") ;If the Handle returned is 0, there was no match
Sleep(1000)
WinWaitActive($handle) ;Wait for the program to be activated
Send("{TAB}") ;send keystrokes to active window
Send("{TAB}")
For $i = 0 to UBound($list) - 1 ;Find the IP address that matches the selection and send it
If $list[$i][0] = $selection Then Send($list[$i][1])
Next
Send("{ENTER}")
Exit ;Exit for now until you can capture a succesful run
EndFunc
func _GetHandleFromPID($PID) ;Call function with the PID returned from Run function
$WinList = WinList() ;Assign WinList to a variable
for $i = 1 to $WinList[0][0] ;Run through each Window in WinList, 2D array [titles][handles]
If WinGetProcess($WinList[$i][1]) = $PID then ;Look for a Window with the correct PID
Return $WinList[$i][1] ;Assign the matching Windows handle to the variable
EndIf
Next
Return 0 ;Return 0 if no matches were found
EndFunc
Func help()
ShellExecute(#TempDir & "\" & $Title & "\config.ini")
EndFunc
#EndRegion--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Once again, any help would be greatly appreciated in helping me finish this project I started months ago. Also, if you think this would be easier to achieve in a different programming language like python or AutoHotkey, please let me know! :)
My apologies on going MIA. I got really busy with things and did not find time to look into the details of the software.
Essentially what is happening is the PID returned is associated with a process called CiceroUIWndFrame (a parent process running in the background) and it is returning the handle of that process. Since that process never get's activated the script just stays paused waiting for it to pop up. Unfortunately due to the fact that the Milestone software does not have it's own PID (look at the Details tab within task manager, you will notice the Milestone software is just called client.exe) we cannot use a good method to obtain the correct handle.
The only solution that I am aware of is to obtain the handle of the active window. So this modified script will run the Milestone X Protect Software, wait 1 second (hopefully long enough to start) and obtain the handle of whatever program is active. It then sleeps for 4 additional seconds, and waits for you to activate the client again. So if you are in another window and wait several minutes, the moment you activate the client login again it will send the keystrokes.
The downfall to this method is that you are relying on the active window after launch to be Milestone (if it takes longer to load, you get the wrong handle, if you click out of focus before 1 second you get the wrong handle).
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <ComboConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>
#include <AutoItConstants.au3>
#Region EDIT THE BELOW INFORMATION-------------------------------------------------------------------------------------------------------------------------------------------
Local Const $milestone = "C:\Program Files\Milestone\XProtect Smart Client\Client.exe" ;Path to software
Local $Title = "Program Title" ;Give me a name
Local $icon = "Full\Path\To\Icon.ico"
#EndRegion-------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Region Script---------------------------------------------------------------------------------------------------------------------------------------------------------------
Local $iFileExists = FileExists($milestone) ;Check if the file exists, returns a 1 or 0
Global $list = IniReadSection(#TempDir & "\" & $Title & "\config.ini","Server") ;Read the ini file, this builds a 2D Array [X][0] is the key [X][1] is the value
HotKeySet("{F1}", "help")
If $iFileExists Then ;If FileExists = 1 (exists) then
If Not FileExists(#TempDir & "\" & $Title) Then ;If config directory does not exists then
Do
DirCreate(#TempDir & "\" & $Title) ;Create a directory in TempDir for the config.ini file to be stored locally
Until FileExists(#TempDir & "\" & $Title)
IniWrite(#TempDir & "\" & $Title & "\config.ini", "Server", "", "")
EndIf
Local $GUI = GUICreate($Title, 267, 115) ;Create the GUI
GUISetIcon($icon, -1) ;Create icon
$start = GUICtrlCreateButton("Start", 40, 72, 65, 25) ;Create a button
$create = GUICtrlCreateButton("Add Server", 160, 72, 65, 25)
$server = GUICtrlCreateCombo("Select Server", 8, 8, 249, 25, $CBS_DROPDOWN) ;Create the combo box
For $i = 1 To UBound($list) - 1 ;Populate combo box with first value (name) from array
If $list[$i][0] <> "" Then GUICtrlSetData($server, $list[$i][0]) ;Ensure array is not empty and fill combox with KEYS
Next
$servername = GUICtrlCreateInput("Server Name", 8, 40, 121, 21)
GUICtrlSetState(-1, $GUI_HIDE)
$serverip = GUICtrlCreateInput("IP Address", 136, 40, 121, 21)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(#SW_SHOW)
While 1 ;Enter loop until user closes or presses button
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE ;Exit when closed
Exit
Case $start ;Store selection into variable, delete the GUI, and run the start function
$selection = GUICtrlRead($server)
If $selection <> "Select Server" Then
GUIDelete()
start()
EndIf
Case $create
If GUICtrlRead($create) = "Add Server" Then
GUICtrlSetState($servername, $GUI_SHOW)
GUICtrlSetState($serverip, $GUI_SHOW)
GUICtrlSetData($create, "Create")
Else
If (GUICtrlRead($servername) <> "" And GUICtrlRead($servername) <> "Server Name" And GUICtrlRead($serverip) <> "" And GUICtrlRead($serverip) <> "IP Address") Then
IniWrite(#TempDir & "\" & $Title & "\config.ini", "Server", GUICtrlRead($servername), GUICtrlRead($serverip))
GUICtrlSetState($servername, $GUI_HIDE)
GUICtrlSetState($serverip, $GUI_HIDE)
GUICtrlSetData($create, "Add Server")
Else
MsgBox($MB_ICONINFORMATION, $Title, "Invalid Server Name and IP Address.")
EndIf
For $i = UBound($list) - 1 To 0 Step -1
_GUICtrlComboBox_DeleteString($server, $i)
Next
Local $list = IniReadSection(#TempDir & "\" & $Title & "\config.ini","Server")
For $i = 1 To UBound($list) - 1
If $list[$i][0] <> "" Then GUICtrlSetData($server, $list[$i][0])
Next
EndIf
EndSwitch
WEnd
Else ;otherwise, message
MsgBox($MB_SYSTEMMODAL, "", "Milestone XProtect wasn't found on this computer" & #CRLF)
EndIf
Func start()
$iPID = Run($milestone) ;Runs the software and returns the Process ID
BlockInput(1)
Sleep(1000) ;sleep for 1 second
BlockInput(0)
If #error Then MsgBox(0, $Title, "The program could not launch.") Exit ;If Run returns a 0 or error, there was a problem
$handle = WinGetHandle("[ACTIVE]") ;Get the handle of the active window, should be Milestone software as it was just ran 1 second ago.
If $handle = 0 Then MsgBox(0, $Title, "The handle could not be found.") Exit;If the Handle returned is 0, there was no match
Sleep(4000)
WinWaitActive($handle) ;Wait for the program to be activated
Send("{TAB}") ;send keystrokes to active window
Send("{TAB}")
For $i = 0 to UBound($list) - 1 ;Find the IP address that matches the selection and send it
If $list[$i][0] = $selection Then Send($list[$i][1])
Next
Send("{ENTER}")
Exit ;Exit for now until you can capture a succesful run
EndFunc
Func help()
ShellExecute(#TempDir & "\" & $Title & "\config.ini")
EndFunc
#EndRegion--------------------------------------------------------------------------------------------------------------------------------------------------------------------
The added/modified lines is as follows, in order:
#include <AutoItConstants.au3>
$iPID = Run($milestone) ;Removed the #shownoactivate parameter, we want it to be the active window. Very important.
BlockInput(1) ;suggestion from comment, disables all input briefly
Sleep(1000) ;wait 1 second for program to launch
BlockInput(0) ;enables all user input again
If #error Then MsgBox(0, $Title, "The program could not launch.") Exit
$handle = WinGetHandle("[ACTIVE]") ;Get the handle of the active window, should be Milestone software as it was just ran 1 second ago.
If $handle = 0 Then MsgBox(0, $Title, "The handle could not be found.") Exit
Sleep(4000)
I tested this with the software on my end and it worked.

win32com and SAP-GUI

My SAP-GUI has Scripting installed and Scripting is enabled.
Like in this screenshot:
In this Introduction to SAP GUI Scripting in "Step 2: Setup your SAP System" you need to call RZ11.
I don't have permissions to call RZ11.
Is there a way to detect this (sapgui/user_scripting on or off) via a script?
At the moment I use below code, but the list of connections is always empty:
import win32com.client
shell = win32com.client.Dispatch("WScript.Shell")
sapgui = win32com.client.GetObject("SAPGUI")
system = query.get('system')
client = query.get('mandant')
session = False
application = sapgui.GetScriptingEngine
seen = []
for i_conn in range(0, application.Connections.Count):
seen.append('i_conn=%s session_count=%s' % (i_conn, application.Connections.Item(i_conn).Sessions.Count))
for i_sess in range(0, application.Connections.Item(i_conn).Sessions.Count):
session_info = application.Connections.Item(i_conn).Sessions.Item(i_sess).Info
system_of_session = session_info.SystemName
client_of_session = session_info.Client
if system_of_session == system and client_of_session == client:
connection = application.Connections.Item(i_conn).Children(i_sess)
session = connection.Children(i_sess)
break
seen.append('system=%s client=%s' % (system_of_session, client_of_session))
if session:
break
else:
info_popup('You are not logged into system %s in Client %s! Seen:\n%s' % (
system, client, '\n'.join(seen)))
return
When you don't have sufficient priviledges in sap, the fact that you can't connect is a pretty good indication that the user does not have scripting enable (assuming the user has a active sap session running), other wise you could just test with 'session.findById("wnd[0]/usr/tblSAPLCMDITCTRL_3500").getAbsoluteRow(3).selected = true' and check for errors.
Also, I suggest you factor in "SAPGUISERVER' in your sapgui = win32com.client.GetObject("SAPGUI") connection if "SAPGUI" fails.
As I know sapgui/user_scripting is a system-level = application level setting but not a user-level. So, if you have no permissions to run RZ11 tcode then you have no opportunity or permissions to read applicaton server settings and, of course, no permissions to change it. You have to contact your basis administrator to verify this application settings with him.
You see, SAP limited scripting abilities due to possible vulnerability, that's why scripting support should be turned on both on client side and on application server side.
If you have access to interrogate the registery you could write a cutom function to check SAPGUI is installed and flagged e.g:
Public Sub CheckKey()
Const cRegKey As String = "HKEY_CURRENT_USER\Software\SAP\SAPGUI Front\SAP Frontend Server\Security\UserScripting"
If CheckSAPGUI(cRegKey) Then
MsgBox "User has SAPGUI installed and initialized", vbOKOnly Or vbInformation, Application.Name
Else
MsgBox "User does not have SAPGUI installed", vbOKOnly Or vbCritical, Application.Name
End If
End Sub
Public Function CheckSAPGUI(RegKey As String) As Boolean
Dim rtn As Variant
On Error Resume Next
rtn = vbNullString
With CreateObject("wscript.shell")
rtn = .RegRead(RegKey)
End With
If Len(rtn) = 0 Then
CheckSAPGUI = False
ElseIf Val(rtn) <> 1 Then
CheckSAPGUI = False
Else
CheckSAPGUI = True
End If
On Error GoTo 0
End Function
You should be able to modify the MsgBox comments to better suit how you want to interact with your end user

Unable to make a connection to ALM 12.5 using vb macro

I have 2 ALM's (11 and 12.5), with the below code, i am able to connect to ALM11, but it says invalid user name and password for 12.5 ALM, (user credentials are correct)
Function ALM_Connection(ByRef TDConnection, server, user, pwd)
On Error Resume Next
Dim fileArray
almLogin.connectionMessage.ForeColor = vbBlue
Set TDConnection = CreateObject("tdconnection")
sUserName = user
sPassword = pwd
If Trim(sUserName) = "" Or Trim(sPassword) = "" Then
almLogin.connectionMessage.ForeColor = vbRed
almLogin.connectionMessage.Caption = "Please Enter the data and click on 'Authenticate'"
ALM_Connection = False
Exit Function
End If
almLogin.connectionMessage.Caption = " Please Wait.. "
Application.Wait (Now + TimeValue("0:00:02"))
TDConnection.InitConnectionEx server
TDConnection.Login sUserName, sPassword
If (TDConnection.loggedin <> True) Then
almLogin.connectionMessage.ForeColor = vbRed
almLogin.connectionMessage.Caption = "Invalid UserName or Password"
ALM_Connection = False
Exit Function
Else
almLogin.connectionMessage.Caption = "Logged In Successfully"
ALM_Connection = True
End If
End Function
any help is appreciated
I generally use the below syntax to create the OTA object
Set TDconnection = CreateObject("tdapiole80.tdconnection")
However, Since the connection and authentication are enclosed inside "On Error Resume Next", the error message may not actually reflect the real cause.
So, this is what I would do to debug.
Remove the On Error Resume Next and check whether the code can create a TDConnection Object
Installing the correct version of HP ALM Addin.
Console out "err.description" to understand the real cause
As I can see from your code it throws message "Invalid UserName or Password" in any case when TDConnection.loggedin property is not True, but it can be because of other reason, e.g. wrong OTAClient.dll library (they are not backward compatible). So in general case you should register your ALM client on the machine (server_url/qcbin -> Tools -> Register client) and then try one more time.
If it doesn't help, you can try to rewrite your code using sample from official documentation http://alm-help.saas.hpe.com/en/12.50/api_refs/ota/topic96.html
This problem is due to the Project unavailable. Also check if you have access to any one of the projects in the v12.5.
Thanks.

How to stop script from automatically closing?

I open an .exe file but the script immediately closes after opening it. How can I prevent the script from closing?
Local $engine= "C:\Users\Davis\Desktop\chessEngine\stockfish-5-win\Windows\stockfish_14053109_32bit.exe"
Run($engine, "", #SW_MAXIMIZE, $STDOUT_CHILD)
Removing $STOUT_CHILD from Run() leaves the script open after executing, but I need this to read output from the program. Why is this happening?
Local $engine = "C:\Users\Davis\Desktop\chessEngine\stockfish-5-win\Windows\stockfish_14053109_32bit.exe"
Local $iPID = Run($engine, "", #SW_MAXIMIZE, $STDOUT_CHILD)
ProcessWaitClose($iPID)
This ist an example how to get output from a DOS command.
ConsoleWrite(_getDOSOutput('ipconfig /all') & #CRLF)
Func _getDOSOutput($command)
Local $text = '', $Pid = Run('"' & #ComSpec & '" /c ' & $command, '', #SW_HIDE, 2 + 4)
While 1
$text &= StdoutRead($Pid, False, False)
If #error Then ExitLoop
Sleep(10)
WEnd
Return StringStripWS($text, 7)
EndFunc ;==>_getDOSOutput

Google Chrome command line link with named tags from a vb string

I have a series of HTTP links stored in the database the have a named tag as part of the link (e.g. http://somecompany.com/products#123332) which represents a product 123332 in a rather large page.
The above link works fine when using IE but doesn't work with Chrome. The # character gets converted to %23 and Chrome can't find the ref. Changing the %23 back to # in the browser's address field works correctly.
The link is stored in a standard VB String and I've tried replacing the # with different values via String.Replace(). There must be a proper way to encode this correctly, I just can't seem to find any references on the web that seem to work.
A simplified example of the call would be something like:
Shell(strBrowser & strLink)
where strBrowser contains all the necessary path and exe name and the strLink is a string similar to what I mentioned above. Also as mentioned it works fine with IE. How can I go about encoding this correctly?
Thanks.
The code
If oFichierAide.LienIntern = 1 Then
strLink = " " + Chr(34) + VarGlobales.EmplacementAppl + oFichierAide.LienFichier + Chr(34)
Else
strLink = " " + Chr(34) + oFichierAide.LienFichier + Chr(34)
End If
Try
regBrowserKey = My.Computer.Registry.ClassesRoot.OpenSubKey("HTTP\shell\open\command", False)
strBrowser = regBrowserKey.GetValue(Nothing).ToString().ToLower().Replace(Chr(34), "")
strBrowser = strBrowser.Substring(0, strBrowser.LastIndexOf(".exe") + 4)
Finally
If regBrowserKey IsNot Nothing Then
regBrowserKey.Close()
End If
End Try
If strBrowser.Length > 0 And strLink.Length > 1 Then
Dim strCall As String = strBrowser + strLink
Shell(strCall, AppWinStyle.NormalFocus, False)
Return True
End If
You can open any chrome window to any URL stored with a string variable via Visual Basic by doing:
Dim appData As String = GetFolderPath(SpecialFolder.ApplicationData)
Dim chromelocation = appdata + "\Local\Google\Chrome\Application\chrome.exe"
process.start(chromelocation + strLink)
Chrome should then open up and the address it goes to should be the contents of strLink.