如何手动进入自动运行脚本?

时间:2016-03-27 02:03:14

标签: batch-file cmd windows-7 autorun

我想在win7中手动操作自动运行脚本。 我的操作:
步骤1登录cmd控制台以管理员身份运行该命令。

D:\wamp\wampmanager.exe

步骤2在cmd控制台中输入超时命令。

timeout  10

step3将数据加载到我的wordpress数据库

mysql -u root -ppasswd wpdatabase < e:/back.sql 

现在我将命令写为start.bat并将其保存在启动目录中。

D:\wamp\wampmanager.exe
timeout  10
mysql -u root -ppasswd wpdatabase < e:/back.sql 

没有效果。

重要的是让start.bat以管理员身份运行,如何在启动阶段自动以管理员身份运行start.bat?如何解决?

2 个答案:

答案 0 :(得分:0)

这是一个允许在shell对象(如文件)上运行右键单击命令的vbscript。双击它以获取帮助。

        

Windows脚本宿主

           

<强> ShVerb

     

在文件或文件夹上列出或运行资源管理器动词(右键菜单)

     

ShVerb <filename> [verb]

     

在没有动词的情况下使用它会列出可用于文件或文件夹的动词

     

该程序列出大多数动词,但仅列出第一个分隔符

之上的动词      使用这种方式的菜单工作

     

可以使用属性动词。但是程序必须继续运行

     

保持属性对话框打开。它通过显示

继续运行      

一个消息框。

           

好的

     
HelpMsg = vbcrlf & "  ShVerb" & vbcrlf & vbcrlf & "  David Candy 2014" & vbcrlf & vbcrlf & "  Lists or runs an explorer verb (right click menu) on a file or folder" & vbcrlf  & vbcrlf & "    ShVerb <filename> [verb]" & vbcrlf & vbcrlf & "  Used without a verb it lists the verbs available for the file or folder" & vbcrlf & vbcrlf
HelpMsg = HelpMsg & "  The program lists most verbs but only ones above the first separator" & vbcrlf & "  of the menu work when used this way" & vbcrlf & vbcrlf 
HelpMsg = HelpMsg & "  The Properties verb can be used. However the program has to keep running" & vbcrlf & "  to hold the properties dialog open. It keeps running by displaying" & vbcrlf & "  a message box." 
Set objShell = CreateObject("Shell.Application")
Set Ag = WScript.Arguments 
set WshShell = WScript.CreateObject("WScript.Shell") 
Set fso = CreateObject("Scripting.FileSystemObject")

    If Ag.count = 0 then 
        wscript.echo "  ShVerb - No file specified"
        wscript.echo HelpMsg 
        wscript.quit
    Else If Ag.count = 1 then 
        If LCase(Replace(Ag(0),"-", "/")) = "/h" or Replace(Ag(0),"-", "/") = "/?" then 
            wscript.echo HelpMsg 
            wscript.quit
        End If
    ElseIf Ag.count > 2 then 
        wscript.echo vbcrlf & "  ShVerb - To many parameters" & vbcrlf & "  Use quotes around filenames and verbs containing spaces"  & vbcrlf
        wscript.echo HelpMsg 
        wscript.quit
    End If

    If fso.DriveExists(Ag(0)) = True then
        Set objFolder = objShell.Namespace(fso.GetFileName(Ag(0)))
'       Set objFolderItem = objFolder.ParseName(fso.GetFileName(Ag(0)))
        Set objFolderItem = objFolder.self
        msgbox ag(0)
    ElseIf fso.FolderExists(Ag(0)) = True then
        Set objFolder = objShell.Namespace(fso.GetParentFolderName(Ag(0)))
        Set objFolderItem = objFolder.ParseName(fso.GetFileName(Ag(0)))
    ElseIf fso.fileExists(Ag(0)) = True then
        Set objFolder = objShell.Namespace(fso.GetParentFolderName(Ag(0)))
        Set objFolderItem = objFolder.ParseName(fso.GetFileName(Ag(0)))
    Else
        wscript.echo "  ShVerb - " & Ag(0) & " not found"
        wscript.echo HelpMsg 
        wscript.quit
    End If

    Set objVerbs = objFolderItem.Verbs

    'If only one argument list verbs for that item

    If Ag.count = 1 then
        For Each cmd in objFolderItem.Verbs
            If len(cmd) <> 0 then CmdList = CmdList & vbcrlf & replace(cmd.name, "&", "") 
        Next
        wscript.echo mid(CmdList, 2)

    'If two arguments do verbs for that item

    ElseIf Ag.count = 2 then
        For Each cmd in objFolderItem.Verbs
            If lcase(replace(cmd, "&", "")) = LCase(Ag(1)) then 
                wscript.echo(Cmd.doit)
                Exit For
            End If
        Next
    'Properties is special cased. Script has to stay running for Properties dialog to show.
        If Lcase(Ag(1)) = "properties" then
            WSHShell.AppActivate(ObjFolderItem.Name & " Properties")
            msgbox "This message box has to stay open to keep the " & ObjFolderItem.Name & " Properties dialog open."
        End If  
    End If
End If

答案 1 :(得分:0)

你是说CGPointMake(CGRectGetMinX(self.frame), CGRectGetMidY(self.frame)); 导致脚本以管理员身份运行吗?

SO上已经有很多很多文章概述了如何以管理员身份运行脚本。

您的问题可能是您尝试运行d:\wamp... - 尝试将其重命名为start.bat,因为startmysql.bat是内部start命令。