Copy Code code as follows:
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.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 (&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 (+, "*") &vbcrlf
End Sub