2016-09-06 49 views
0

对脚本编程不熟悉,需要一些帮助。我需要菜单保持打开状态(显示在用户屏幕上),如果他们选择和运行1-8的任何东西,但如果他们选择第9项,我需要它退出。需要菜单代码的协助

预先感谢您!

Titre = "Select One Item - IT Config Dept 2016" 
"Select One at a Time"&vbcr&vbcr&_ 
"1 - Map Mastercd "&vbcr&_ 
"2 - Shortcuts "&vbcr&_ 
"3 - Customize Windows "&vbcr&_ 
"4 - IE Setup "&vbcr&_ 
"5 - Notetab "&vbcr&_ 
"6 - Outlook Setup "&vbcr&_ 
"7 - AS400 & New GUI "&vbcr&_ 
"8 - AMS "&vbcr&_ 
"9 - Exit " 

Default ="1" 
Question = InputBox(message,Titre,Default) 
Select Case Question 
Case 1 Run(1) 
Case 2 Run(2) 
Case 3 Run(3) 
Case 4 Run(4) 
Case 5 Run(5) 
Case 6 Run(6) 
Case 7 Run(7) 
Case 8 Run(8) 
Case 9 Run(9) 


end Select 


Sub Run(var) 
Set WS = CreateObject("WScript.shell") 
    Select Case var 
    Case 1 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Mapping_Mastercd\Mapping_Mastercd.bat") 
    Case 2 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Shortcuts_done\Shortcuts.bat") 
    Case 3 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Setup_done\Taskbar_combined.vbs") 
    Case 4 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Iexplorer_done\IE_setup.vbs") 
    Case 5 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Notepab_done\Notetab_combined.vbs") 
    Case 6 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Outlook_done\Outlook.vbs") 
    Case 7 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\AS400\ASW_Setup.vbs") 
    Case 8 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\AMS_done\AMS_combined.vbs") 
    Case 9 WS.run("Exit code") 

End select 
End Sub 

' case 1 

Sub Mapping(Process) 
Set Ws = CreateObject("Wscript.Shell") 
Command = "cmd /c Taskkill /F /IM "&Process&"" 
Execution = Ws.Run(Command,0,False) 
End Sub 

' case 2 

Sub Shortcuts(Process) 
Set Ws = CreateObject("Wscript.Shell") 
Command = "cmd /c Taskkill /F /IM "&Process&"" 
Execution = Ws.Run(Command,0,False) 
End Sub 

Function CmdPrompt(sCmd) 
Dim sCmdLine,oWS,nRes 
set oWS = CreateObject("Wscript.Shell") 
sCmdLine = "cmd /c Start " & sCmd & "" 
nRes = oWS.Run(sCmdLine,0,False) 
CmdPrompt = nRes 
End Function 

' case 3 

Sub Customizewindows(Process) 
Set Ws = CreateObject("Wscript.Shell") 
Command = "cmd /c Taskkill /F /IM "&Process&"" 
Execution = Ws.Run(Command,0,False) 
End Sub 

Function CmdPrompt(sCmd) 
Dim sCmdLine,oWS,nRes 
set oWS = CreateObject("Wscript.Shell") 
sCmdLine = "cmd /c Start " & sCmd & "" 
nRes = oWS.Run(sCmdLine,0,False) 
CmdPrompt = nRes 
End Function 

' case 4 

Sub IEsetup(Process) 
Set Ws = CreateObject("Wscript.Shell") 
Command = "cmd /c Taskkill /F /IM "&Process&"" 
Execution = Ws.Run(Command,0,False) 
End Sub 

Function CmdPrompt(sCmd) 
Dim sCmdLine,oWS,nRes 
set oWS = CreateObject("Wscript.Shell") 
sCmdLine = "cmd /c Start " & sCmd & "" 
nRes = oWS.Run(sCmdLine,0,False) 
CmdPrompt = nRes 
End Function 

' case 5 

Sub Notetab(Process) 
Set Ws = CreateObject("Wscript.Shell") 
Command = "cmd /c Taskkill /F /IM "&Process&"" 
Execution = Ws.Run(Command,0,False) 
End Sub 

Function CmdPrompt(sCmd) 
Dim sCmdLine,oWS,nRes 
set oWS = CreateObject("Wscript.Shell") 
sCmdLine = "cmd /c Start " & sCmd & "" 
nRes = oWS.Run(sCmdLine,0,False) 
CmdPrompt = nRes 
End Function 

' case 6 

Sub Outlook(Process) 
Set Ws = CreateObject("Wscript.Shell") 
Command = "cmd /c Taskkill /F /IM "&Process&"" 
Execution = Ws.Run(Command,0,False) 
End Sub 

Function CmdPrompt(sCmd) 
Dim sCmdLine,oWS,nRes 
set oWS = CreateObject("Wscript.Shell") 
sCmdLine = "cmd /c Start " & sCmd & "" 
nRes = oWS.Run(sCmdLine,0,False) 
CmdPrompt = nRes 
End Function 

' case 7 

Sub AS400(Process) 
Set Ws = CreateObject("Wscript.Shell") 
Command = "cmd /c Taskkill /F /IM "&Process&"" 
Execution = Ws.Run(Command,0,False) 
End Sub 

Function CmdPrompt(sCmd) 
Dim sCmdLine,oWS,nRes 
set oWS = CreateObject("Wscript.Shell") 
sCmdLine = "cmd /c Start " & sCmd & "" 
nRes = oWS.Run(sCmdLine,0,False) 
CmdPrompt = nRes 
End Function 

' case 8 

Sub AMS(Process) 
Set Ws = CreateObject("Wscript.Shell") 
Command = "cmd /c Taskkill /F /IM "&Process&"" 
Execution = Ws.Run(Command,0,False) 
End Sub 

Function CmdPrompt(sCmd) 
Dim sCmdLine,oWS,nRes 
set oWS = CreateObject("Wscript.Shell") 
sCmdLine = "cmd /c Start " & sCmd & "" 
nRes = oWS.Run(sCmdLine,0,False) 
CmdPrompt = nRes 
End Function 
+0

请参见[MCVE]和[提问],并尝试[编辑]你的问题要缩小到一个*特定*问题。 –

回答

0

只需创建一个循环,退出9

while Question <> 9 
     Question = InputBox(message,Titre,Default) 

     Select Case Question 
      Case 1 Run(1) 
      Case 2 Run(2) 
      Case 3 Run(3) 
      Case 4 Run(4) 
      Case 5 Run(5) 
      Case 6 Run(6) 
      Case 7 Run(7) 
      Case 8 Run(8) 
      Case 9 Run(9) 
     end Select 

    wend 
0

你可以做这样的事情:

Title="Menu Selector : IT Config Dept 2016" 
message = "Select One at a Time"&vbcr&vbcr&_ 
"1 - Map Mastercd "&vbcr&_ 
"2 - Shortcuts "&vbcr&_ 
"3 - Customize Windows "&vbcr&_ 
"4 - IE Setup "&vbcr&_ 
"5 - Notetab "&vbcr&_ 
"6 - Outlook Setup "&vbcr&_ 
"7 - AS400 & New GUI "&vbcr&_ 
"8 - AMS "&vbcr&_ 
"9 - Exit " 

Do 
    response = InputBox(message,Title,9) 
    If response = "" Then WScript.Quit 'Detect Cancel 
    If IsNumeric(response) Then Exit Do 'Detect value response. 
    MsgBox "You must enter a numeric value.", 48, "Invalid Entry" 
Loop 

Select Case response 
Case 1 Run(1) 
Case 2 Run(2) 
Case 3 Run(3) 
Case 4 Run(4) 
Case 5 Run(5) 
Case 6 Run(6) 
Case 7 Run(7) 
Case 8 Run(8) 
Case 9 Run(9) 
end Select 


Sub Run(var) 
Set WS = CreateObject("WScript.shell") 
    Select Case var 
    Case 1 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Mapping_Mastercd\Mapping_Mastercd.bat") 
    Case 2 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Shortcuts_done\Shortcuts.bat") 
    Case 3 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Setup_done\Taskbar_combined.vbs") 
    Case 4 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Iexplorer_done\IE_setup.vbs") 
    Case 5 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Notepab_done\Notetab_combined.vbs") 
    Case 6 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\Outlook_done\Outlook.vbs") 
    Case 7 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\AS400\ASW_Setup.vbs") 
    Case 8 WS.run("\\usprsfs11\IT\IT_notes\!PC_ConfigDoc\Bryan\Autohotkey\64_bit_Menu\AMS_done\AMS_combined.vbs") 
    Case 9 wscript.quit() 
End select 
End Sub 
+0

嗨,感谢您的帮助,但是在应用更改之后,我现在收到一条错误消息,并且无法确定问题出现在代码中的哪个位置。你可以请我的编码,看看我失踪了吗? – NJTek911

+0

对不起,忘了提及代码在得到错误信息后运行。如果代码没有出现,请让我知道,我会重新贴上它 – NJTek911