使用batch file打开Internet选项,打开连接选项卡,按确定

这是为Windows 7电脑

我正在运行一个batch file.bat ),并且想要将其configuration为打开Internet选项,然后按“连接”选项卡,然后按“确定”。

到目前为止,我已经得到了以下内容,打开Internet选项:

 inetcpl.cpl 

我一直在尝试遵循这个链接上最有回报的答案来做到这一点,使用以下,但它不工作,甚至打开Internet选项:

 Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run inetcpl.cpl 

另存为.bat

 @if (@X)==(@Y) @end /* JScript comment @echo off cscript //E:JScript //nologo "%~f0" exit /b %errorlevel% @if (@X)==(@Y) @end JScript comment */ var WshShell = new ActiveXObject("WScript.Shell"); WshShell.Run("control inetcpl.cpl"); WshShell.AppActivate("Internet Properties"); WScript.Sleep(100); WshShell.SendKeys("+{TAB}"); WScript.Sleep(100); WScript.Echo("RIGHT keys....."); WshShell.SendKeys("{RIGHT}"); WScript.Sleep(100); WshShell.SendKeys("{RIGHT}"); WScript.Sleep(100); WshShell.SendKeys("{RIGHT}"); WScript.Sleep(100); WshShell.SendKeys("{RIGHT}"); WScript.Sleep(100); //WshShell.SendKeys("{RIGHT}"); WshShell.SendKeys("{TAB}"); WScript.Sleep(100); WshShell.SendKeys("{TAB}"); WScript.Sleep(100); WshShell.SendKeys("{TAB}"); WScript.Sleep(100); WshShell.SendKeys("{TAB}"); WScript.Sleep(100); WshShell.SendKeys("{TAB}"); WScript.Sleep(100); WshShell.SendKeys("{TAB}"); WScript.Sleep(100); WshShell.SendKeys("{ENTER}"); 

我已经使用@npocmaka的最大的答案,并在这个问题上回答

您可以将下面的脚本保存为bat文件并运行它。

 @if (@X)==(@Y) @end /* JScript comment @echo off cscript //E:JScript //nologo "%~f0" exit /b %errorlevel% @if (@X)==(@Y) @end JScript comment */ var WshShell = new ActiveXObject("WScript.Shell"); WshShell.Run("rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,4"); WshShell.AppActivate("Internet Properties"); WScript.Sleep(100); WshShell.SendKeys("{TAB}"); WScript.Sleep(100); WshShell.SendKeys("{TAB}"); WScript.Sleep(100); WshShell.SendKeys("{TAB}"); WScript.Sleep(100); WshShell.SendKeys("{TAB}"); WScript.Sleep(100); WshShell.SendKeys("{TAB}"); WScript.Sleep(100); WshShell.SendKeys("{ENTER}"); 

我会添加评论到@npocmaka答案,但我没有足够的声誉在这里添加任何评论。 我希望它能帮助别人。

这是一个字符串,必须在引号中。

我不明白的是为什么你毫无意义地发布代码没有错误。

 --------------------------- Windows Script Host --------------------------- Script: C:\Users\User\Desktop\a.vbs Line: 2 Char: 1 Error: Object required: 'inetcpl' Code: 800A01A8 Source: Microsoft VBScript runtime error --------------------------- OK ---------------------------