2016-03-27 24 views
-1

win7で手作業で自動実行スクリプトにしたいです。 私の操作:
ステップ1 cmdコンソールにログインして、管理者としてコマンドを実行します。自動実行スクリプトに手動で操作する方法は?

D:\wamp\wampmanager.exe 

ステップ2 cmdoutでtimeoutコマンドを入力します。

timeout 10 

今私がSTART.BATのようにコマンドを記述し、起動ディレクトリに保存し、私のワードプレスのデータベース

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

にデータをロードするSTEP3。

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

効果はありません。

重要なのは、start.batを管理者として実行することです。起動時にstart.batを管理者として自動的に実行する方法はありますか?

答えて

0

ファイルなどのシェルオブジェクトに対して右クリックコマンドを実行できるvbscriptがあります。ダブルクリックするとヘルプが表示されます。


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...スクリプトは管理者として実行されるようにするというOUされていますか?

すでに管理者としてスクリプトを実行する方法を概説しているので、すでに多くの記事があります。

あなたの問題は、あなたがstart.batを実行しようとしているのかもしれ - startは内部cmdコマンドですので、startmysql.batに名前を変更してみてください。

関連する問題