-1

ok so I was creating an HTML that opens without toolbars or anything just by itself but I can't make it work for other computers

this is what I got

set webbrowser = createobject("internetexplorer.application")

webbrowser.statusbar = false

webbrowser.menubar = false

webbrowser.toolbar = false

webbrowser.visible = true

webbrowser.navigate2 ("C:\Users\unknown\Desktop\Folder\myhtml.html")

2 Answers2

0

Use the UserName property of the ActiveX-object "WScript.Network" to obtain the name of the current user on the other computers.

As in:

>> sUser = CreateObject("WScript.Network").UserName
>> WScript.Echo "Just for Demo:", sUser
>>
Just for Demo: eh

(That object is different from the WScript object provided by the C|WScript.exe host, so it's usable from other host. Not using the browser (.html), but the mshta.exe host (.hta) - as @omegastripes proposes - is sound advice.)

Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96
0

You should handle that:

  • The user desktop folder location can be changed
  • The desktop a user sees is a virtual view of more than one folder in the filesystem. Directly searching for the folder inside the user desktop will leave out the desktop folder configured for all the users.

So, it is better to ask the OS to retrieve the required information

Option Explicit

' folder in desktop and file in folder 
Const FOLDER_NAME = "Folder"
Const FILE_NAME = "myhtml.html"

Dim oFolder
Const ssfDESKTOP = &H00&
    ' Retrieve a reference to the virtual desktop view and try to retrieve a reference
    ' to the folder we are searching for
    With WScript.CreateObject("Shell.Application").Namespace( ssfDESKTOP )
        Set oFolder = .ParseName(FOLDER_NAME)
    End With 

    ' If we don't have a folder reference, leave with an error
    If oFolder Is Nothing Then 
        WScript.Echo "ERROR - Folder not found in desktop"
        WScript.Quit 1
    End If 

Dim strFolderPath, strFilePath    
    ' Retrieve the file system path of the requested folder
    strFolderPath = oFolder.Path

    ' Search the required file and leave with an error if it can not be found
    With WScript.CreateObject("Scripting.FileSystemObject")
        strFilePath = .BuildPath( strFolderPath, FILE_NAME )
        If Not .FileExists( strFilePath ) Then 
            WScript.Echo "ERROR - File not found in desktop folder"
            WScript.Quit 1
        End If 
    End With 

    ' We have a valid file reference, navigate to it
    With WScript.CreateObject("InternetExplorer.Application")
        .statusBar = False 
        .menubar = False 
        .toolbar = False 
        .visible = True 
        .navigate2 strFilePath 
    End With 

You can find more information on shell scriptable objects here

MC ND
  • 69,615
  • 8
  • 84
  • 126