好的,所以我正在创建一个HTML,该HTML打开时没有工具栏或其他任何工具,但是我无法使其在其他计算机上正常工作
这就是我得到的
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")
答案 0 :(得分:0)
使用ActiveX对象“ WScript.Network”的UserName属性获取其他计算机上当前用户的名称。
如:
>> sUser = CreateObject("WScript.Network").UserName
>> WScript.Echo "Just for Demo:", sUser
>>
Just for Demo: eh
(该对象不同于C | WScript.exe主机提供的WScript对象,因此可以在其他主机上使用。不是使用浏览器(.html),而是使用mshta.exe主机(.hta)- @omegastripes提出-是合理的建议。)
答案 1 :(得分:0)
您应该处理:
因此,最好让操作系统检索所需的信息
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
您可以找到有关Shell可编写脚本的对象here
的更多信息。