如何运行在隐藏模式下启动时的脚本 [英] How to run a script on startup in hidden mode

查看:139
本文介绍了如何运行在隐藏模式下启动时的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个批处理文件,命名为 prova.bat ,我需要在计算机的启动启动它,我需要启动它在隐藏模式下(没有明显的提示)。

我在网上找到的解决方案,以在启动时或解决方案的推出批量推出在隐藏模式下一批,而不是解决方案,以解决这两个我的问题。我曾尝试用VBScript和设置脚本在启动运行(在SystemConfiguration)。

这个批必须运行的操作系统是Windows 8.1。

下面是VBScript的内容(也许是错误的东西在里面):

 设置的WshShell =的CreateObject(WScript.Shell)
WshShell.Run字符(34)及C:\\程序\\程序\\ prova.bat&放大器;字符(34),0
设置的WshShell =什么


解决方案

这VBScript中可以做的伎俩(测试在Windows 7 32位)

希望将您的 Windows 8的工作;)

所以,code是非常容易使用:你只需要改变就可以了两件事情:


  • PathApplication


  • ShortcutName



 显式的选项
昏暗PathApplication,ShortcutName,VbsPath
VbsPath = Wscript.ScriptFullName
PathApplication =C:\\ signcatcher \\ signcatcher \\ prova.bat
ShortcutName =Hackoo
调用快捷方式(VbsPath,ShortcutName)
呼叫Hidden_​​Run(Dblquote(PathApplication))
******************* ********************************
子快捷方式(PathApplication,ShortcutName)
    暗淡objShell,StartFolder,objShortCut,编辑MyTAB
    设置objShell =的CreateObject(WScript.Shell)
    编辑MyTAB =斯普利特(PathApplication,\\)
    如果ShortcutName =那
        ShortcutName =编辑MyTAB(UBound函数(编辑MyTAB))
    万一
    StartFolder = objShell.SpecialFolders(启动)
    设置objShortCut = objShell.CreateShortcut(StartFolder&安培;\\&放大器; ShortcutName&安培;.LNK)
    objShortCut.TargetPath = Dblquote(PathApplication)
    ObjShortCut.IconLocation =%SYSTEMROOT%\\ SYSTEM32 \\ SHELL32.DLL,-25
    objShortCut.Save
结束小组
******************* ********************************
功能DblQuote(STR)
    DblQuote = CHR(34)及STR和放大器;字符(34)
结束功能
******************* ********************************
功能Hidden_​​Run(MyProgram)
    昏暗的WS,结果
    设置WS =的CreateObject(wscript.Shell)
    结果= ws.run(MyProgram,0,TRUE)0隐藏程序
    Hidden_​​Run =结果
结束功能
******************* ********************************

I have a batch file, named prova.bat, and I need to launch it at the startup of the computer, and I need to launch it in hidden mode (with no visible prompt).

I have found on the net solutions to launch the batch at the startup OR solutions to launch the batch in hidden mode, but not solutions to fix both my problems. I have tried with a VBScript and set the script to run at the startup (in the SystemConfiguration).

The OS where the batch have to run is Windows 8.1.

Here's the content of the VBScript (maybe it's something wrong in it):

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\app\app\prova.bat" & Chr(34), 0
Set WshShell = Nothing

解决方案

This Vbscript can did the trick (Tested on Windows 7 32 bits)

Hope will work on your Windows 8 ;)

So the code is very easy to use : You just change two things on it :

  • PathApplication

  • ShortcutName


Option Explicit
Dim PathApplication,ShortcutName,VbsPath
VbsPath = Wscript.ScriptFullName
PathApplication = "C:\signcatcher\signcatcher\prova.bat"
ShortcutName = "Hackoo"
Call Shortcut(VbsPath,ShortcutName)
Call Hidden_Run(Dblquote(PathApplication))
'*********************************************************************************
Sub Shortcut(PathApplication,ShortcutName)
    Dim objShell,StartFolder,objShortCut,MyTab
    Set objShell = CreateObject("WScript.Shell")
    MyTab = Split(PathApplication,"\")
    If ShortcutName = "" Then
        ShortcutName = MyTab(UBound(MyTab))
    End if
    StartFolder = objShell.SpecialFolders("Startup")
    Set objShortCut = objShell.CreateShortcut(StartFolder & "\" & ShortcutName & ".lnk")
    objShortCut.TargetPath = Dblquote(PathApplication)
    ObjShortCut.IconLocation = "%SystemRoot%\system32\SHELL32.dll,-25"
    objShortCut.Save
End Sub
'*********************************************************************************
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'*********************************************************************************
Function Hidden_Run(MyProgram)
    Dim ws,Result
    Set ws = CreateObject("wscript.Shell")
    Result = ws.run(MyProgram,0,True) '0 to hide the program
    Hidden_Run = Result
End Function
'*********************************************************************************

这篇关于如何运行在隐藏模式下启动时的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆