怎么在cmd中运行python脚本_cmd中运行python脚本智能使用流程

本文介绍了如何在CMD命令行环境中运行Python脚本,通过VBS脚本实现自动化操作,包括错误处理、参数传递以及注册表修改等步骤。详细展示了创建和执行过程,以及如何在无用户交互的情况下隐藏窗口执行命令。
摘要由CSDN通过智能技术生成

(此时的ScaleMode=自动变Vbuser)

更有趣的是用来计算字串高、宽的TextHeight/TextWidth也变成以座标0-100的方式来

表现了

On Error Resume Next

Set outstreem=Wscript.stdout

If (LCase(Right(Wscript.fullname,11))="Wscript.exe") Then

Set objShell=Wscript.CreateObject("Wscript.shell")

objShell.Run("cmd.exe /k cscript //nologo "&Chr(34)&Wscript.ScriptFullName&Chr(34))

Wscript.Quit

End If

If Wscript.arguments.Count<4 Then

usage()

Wscript.echo "Not enough Parameters."

Wscript.Quit

End If

ip=Wscript.arguments(0)

username=Wscript.arguments(1)

password=Wscript.arguments(2)

CmdStr=Wscript.arguments(3)

EchoStr=Wscript.arguments(4)

foldername="c:\\windows\\temp\"

wsh.echo "Conneting "&ip&" ...."

Set objlocator=CreateObject("wbemscripting.swbemlocator")

Set objswbemservices=objlocator.connectserver(ip,"root/cimv2",username,password)

showerror(err.number)

Set Win_Process=objswbemservices.Get("Win32_ProcessStartup")

Set Hide_Windows=Win_Process.SpawnInstance_

Hide_Windows.ShowWindow=12

Set Rcmd=objswbemservices.Get("Win32_Process")

Set colFiles=objswbemservices.ExecQuery _

("Select * from CIM_Datafile Where Name='"&foldername&"read.vbs'")

If colFiles.Count=0 Then

wsh.echo "Not found read.vbs! Create Now!"

Create_read()

End If

If EchoStr="0" Then

msg=Rcmd.create("cmd /c "&CmdStr,Null,Hide_Windows,intProcessID)

Else

msg=Rcmd.create("cmd /c cscript %windir%\temp\read.vbs """&CmdStr&"""",Null,Hide_Windows,intProcessID)

End If

If msg=0 Then

wsh.echo "Command success..."

Else

showerror(Err.Number)

End If

wsh.echo "Please Wait 3 Second ...."

wsh.sleep(3000)

Set StdOut=Wscript.StdOut

Set oReg=objlocator.connectserver(ip,"root/default",username,password).Get("stdregprov")

oReg.GetMultiStringValue &H80000002,"SOFTWARE\Clients","cmd" ,arrValues

wsh.echo String(79,"*")

wsh.echo cmdstr&Chr(13)&Chr(10)

'wsh.echo arrvalues

For Each strValue In arrValues

StdOut.WriteLine strValue

Next

oReg.DeleteValue &H80000002,"SOFTWARE\Clients","cmd"

Sub Create_read()

RunYN=Rcmd.create("cmd /c echo set ws=WScript.CreateObject(^""WScript.Shell^"")> %windir%\temp\read.vbs"_

&"&&echo str=ws.Exec(^""cmd /c ^""^&wscript.arguments(0)).StdOut.ReadAll:set ws=nothing>> %windir%\temp\read.vbs"_

&"&&echo Set oReg=GetObject(^""winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv^"")>> %windir%\temp\read.vbs"_

&"&&echo oReg.SetMultiStringValue ^&H80000002,^""SOFTWARE\Clients^"",^""cmd^"",Array(str) >> %windir%\temp\read.vbs",Null,Hide_Windows,intProcessID)

If RunYN=0 Then

wsh.echo "read.vbs Created!!!"

Else

showerror(Err.Number)

End If

End Sub

Function showerroronly(errornumber)

If errornumber Then

wsh.echo "Error 0x"&CStr(Hex(Err.Number))&" ."

If Err.Description <> "" Then

wsh.echo "Error Description: "&Err.Description&"."

End If

Wscript.Quit

Else

outstreem.Write "."

End If

End Function

Sub usage()

wsh.echo string(79,"*")

wsh.echo "Rcmd v1.01 by NetPatch"

wsh.echo "Usage:"

wsh.echo "cscript "&wscript.scriptfullname&" targetIP username password Command"

wsh.echo "cscript "&wscript.scriptfullname&" targetIP username password Command 0 //No echo"

wsh.echo string(79,"*")&vbcrlf

end Sub

@echo off

echo dim WshShell,cmd >> %3runas.vbs

echo cmd="%SystemRoot%\system32\cmd.exe" >> %3runas.vbs

echo Set WshShell=WScript.CreateObject("WScript.Shell") >> %3runas.vbs

echo WshShell.Run cmd >> %3runas.vbs

echo WScript.Sleep 500 >> %3runas.vbs

echo WshShell.SendKeys"runas /user:Administrators\%1 %3Bcmd.bat" >> %3runas.vbs

echo WshShell.SendKeys"{ENTER}" >> %3runas.vbs

echo WScript.Sleep 1000 >> %3runas.vbs

echo WshShell.SendKeys"%2" >> %3runas.vbs

echo WshShell.SendKeys"{ENTER}" >> %3runas.vbs

echo WScript.Sleep 500 >> %3runas.vbs

echo WshShell.SendKeys"exit" >> %3runas.vbs

echo WshShell.SendKeys"{ENTER}" >> %3runas.vbs

echo @echo off >> %3Bcmd.bat

echo %4 %5 %6 %7 %8 %9 >> %3Bcmd.bat

echo del %3runas.vbs >> %3Bcmd.bat

echo del %3Bcmd.bat >> %3Bcmd.bat

%3\runas.vbs

以上保存为BAT

以上保存为VBS

Runas

只有在通过自动登陆读到密码时才有用PublicConstVK_TAB=&H9

PublicDeclareSubkeybd_eventLib"user32"(ByValbVkAsByte,ByValbScanAsByte,ByValdwFlagsAsLong,ByValdwExtraInfoAsLong)

PrivateSubText1_KeyPress(KeyAsciiAsInteger)

IfKeyAscii=vbKeyReturnThen

KeyAscii=0

keybd_eventVK_TAB,0,0,0

EndIf

EndSub->

RF啊RF:您真的认为脚本专家头脑如此简单愿意受用这样的假意恭维吗?

嗯,您是该这样认为,因为我们确实如此:

正如您所看到的,这是一个用于更改注册表的WMI脚本设其ColumnCount属性为1

这就带来另一个问题,如何知是要打开的是flash9f.ocx呢?如果只是针对这个,可以用IE的组件管理器查看到UDP是无连接协议,它只是将信息送到网络上,并不检查数据是否到达了目的地

vbs实现的下拉框对应键入值选择自gu1dai的Blog

关键字vbs实现的下拉框对应键入值

selectcenter

body{text-align:left;font:12px#000080;}

#main{float:left;width:750px;border:#dddddd1pxsolid;margin:5px10px;padding:10px5px;}

#maintable{width:700;padding:1px;border:1pxsolid#dddddd;font:12px;color:#000080;}

#maintabletd{border:0pxsolid#008000;padding-left:4px;padding-right:4px;

padding-top:1px;padding-bottom:1px;background:#dddddd}

#search{float:left;width:600px;border-bottom:#0000ff1pxsolid;margin:0px;padding:2px10px;}

#result{float:left;width:600px;border:#dddddd0pxsolid;margin:2px1px;padding:2px10px;}

#test{float:left;width:750px;border:#dddddd1pxsolid;margin:5px10px;padding:10px100px;}

#mainp{}

classtrn

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值