2016-03-27 44 views
-1

我想在win7中手工操作自动运行脚本。 我的操作:
step1登录到cmd控制台以管理员身份运行该命令。如何使手动操作进入自动运行脚本?

D:\wamp\wampmanager.exe 

step2在cmd控制台中输入超时命令。

timeout 10 

第三步:将数据加载到我的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?如何解决?

回答

0

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


Windows脚本宿主


ShVerb

列表或运行在一个文件或文件夹

ShVerb <filename> [verb]

探险家动词(右键菜单)

如果不使用它列出了可用于文件或文件夹中的动词动词

程序列表最动词,但唯一的菜单工作的第一隔片

上面用这样的方式

属性时动词可以使用。但程序必须保持运行状态

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

消息框继续运行。


OK


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 
0

正在瓯说,d:\wamp...导致以管理员身份运行该脚本?

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

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