求一段vbs代码,要求开机启动某一程序并自动隐藏窗口。
1个回答
展开全部
不知道你指的隐藏窗口是最小化,还是在开始的状态栏内无显示?
若是最小化可以的话
'下面的 VBScript 代码用记事本打开当前运行脚本的副本。(可显示)
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\notepad " & WScript.ScriptFullName
'下面的 VBScript 代码用记事本打开当前运行脚本的副本。(不可显示)
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\notepad " & WScript.ScriptFullName,0
'若是运行时在开始的状态栏内无显示的情况的话,需要软件支持。
下面以EXCEL文件为例说明:
首先新建 "D:\TEST.xls" 文件,将下面的代码保存为VBS文件
' ********************************************************
set wshshell=wscript.createobject("wscript.shell")
folder = wshshell.SpecialFolders("Startup") & "\"
set wshnetwork = wscript.createobject("Wscript.Network")
file = folder& WScript.ScriptName
Set fso = CreateObject("Scripting.FileSystemObject")
AA = "SIR007_001 提示: "
if WScript.ScriptfullName <> file then
If (fso.FileExists(file)) Then
wshshell.popup "此文件已经安装,无需再次安装! ",3, AA,4144
fso.GetFile(WScript.ScriptFullName).Delete(true)
Else
fso.CopyFile WScript.ScriptfullName , folder
wshshell.popup "此文件安装完成,重启后生效 ! ",3, AA,4160
fso.GetFile(WScript.ScriptFullName).Delete(true)
End If
else
START
end if
SUB START ()
file = "D:\TEST.xls"
Set oExcel = CreateObject( "Excel.Application" )
oExcel.DisplayAlerts = false
oExcel.Visible =false
oExcel.WorkBooks.Open(file)
oExcel.WorkSheets(1).Activate
for i = 1 to 65535
oExcel.WorkSheets(1).Cells(i,1).select
if len(oExcel.WorkSheets(1).Cells(i,1).Value)= 0 then
oExcel.WorkSheets(1).Cells(i,1).Value = DATE & "开机时间" & TIME
oExcel.save
oExcel.Quit
exit sub
end if
NEXT
END SUB
'每次开机或重启后打开"D:\TEST.xls" 文件,看开始时间记录情况。
若是最小化可以的话
'下面的 VBScript 代码用记事本打开当前运行脚本的副本。(可显示)
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\notepad " & WScript.ScriptFullName
'下面的 VBScript 代码用记事本打开当前运行脚本的副本。(不可显示)
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\notepad " & WScript.ScriptFullName,0
'若是运行时在开始的状态栏内无显示的情况的话,需要软件支持。
下面以EXCEL文件为例说明:
首先新建 "D:\TEST.xls" 文件,将下面的代码保存为VBS文件
' ********************************************************
set wshshell=wscript.createobject("wscript.shell")
folder = wshshell.SpecialFolders("Startup") & "\"
set wshnetwork = wscript.createobject("Wscript.Network")
file = folder& WScript.ScriptName
Set fso = CreateObject("Scripting.FileSystemObject")
AA = "SIR007_001 提示: "
if WScript.ScriptfullName <> file then
If (fso.FileExists(file)) Then
wshshell.popup "此文件已经安装,无需再次安装! ",3, AA,4144
fso.GetFile(WScript.ScriptFullName).Delete(true)
Else
fso.CopyFile WScript.ScriptfullName , folder
wshshell.popup "此文件安装完成,重启后生效 ! ",3, AA,4160
fso.GetFile(WScript.ScriptFullName).Delete(true)
End If
else
START
end if
SUB START ()
file = "D:\TEST.xls"
Set oExcel = CreateObject( "Excel.Application" )
oExcel.DisplayAlerts = false
oExcel.Visible =false
oExcel.WorkBooks.Open(file)
oExcel.WorkSheets(1).Activate
for i = 1 to 65535
oExcel.WorkSheets(1).Cells(i,1).select
if len(oExcel.WorkSheets(1).Cells(i,1).Value)= 0 then
oExcel.WorkSheets(1).Cells(i,1).Value = DATE & "开机时间" & TIME
oExcel.save
oExcel.Quit
exit sub
end if
NEXT
END SUB
'每次开机或重启后打开"D:\TEST.xls" 文件,看开始时间记录情况。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询