RogFleming Posted October 25, 2010 Share Posted October 25, 2010 (edited) Here is a a code snip it to allow you to run a program on a remote system as yourself. I'm working on a version which will allow you to set a scheduled task so it will work interactively with the desktop. Currently it is hidden from the desktop. You will have to look in task manager to see the process. Dim $objWMIService, $objProcess Dim $strShell, $objProgram, $strComputer, $strExe, $strInput $strComputer = InputBox("ComputerName to Run Script","Computer Name") $strExe = "notepad.exe" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $objProcess = $objWMIService.Get("Win32_Process") $objProgram = $objProcess.Methods_("Create").InParameters.SpawnInstance_ $objProgram.CommandLine = $strExe ;Execute the program now at the command line. $strShell = $objWMIService.ExecMethod( "Win32_Process", "Create", $objProgram) MsgBox(1,"","Created: " & $strExe & " on " & $strComputer) Edited October 25, 2010 by RogFleming Link to comment Share on other sites More sharing options...
enaiman Posted October 25, 2010 Share Posted October 25, 2010 Well - haven't tried it yet but I will. It looks very promising. It will make a very nice UDF. Thank you for sharing this SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
daluu Posted October 26, 2010 Share Posted October 26, 2010 Thanks for sharing. I can make good use of that WMI technique to do the same in VBScript or .NET. Link to comment Share on other sites More sharing options...
Juvigy Posted October 26, 2010 Share Posted October 26, 2010 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") This line fails for me. Do i need to be logged on the remote computer? Link to comment Share on other sites More sharing options...
spudw2k Posted October 26, 2010 Share Posted October 26, 2010 (edited) $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") This line fails for me. Do i need to be logged on the remote computer?You shouldn't need to be logged into the remote pc.It could fail if you don't have admin rights to the remote machine or if WMI is disabled on it.Also be sure you can ping/reach the machine specified in the $strComputer variable.edit:just some additional infohttp://www.autoitscript.com/forum/index.php?showtopic=44913&view=findpost&p=672678 Edited October 26, 2010 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
UEZ Posted October 26, 2010 Share Posted October 26, 2010 (edited) I'm working on a version which will allow you to set a scheduled task...As far as I can remember you can use SCHTASKS.exe to create scheduled tasks also on remote machines.Br,UEZPS: reached 1000 Edited October 26, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Juvigy Posted October 27, 2010 Share Posted October 27, 2010 You shouldn't need to be logged into the remote pc.It could fail if you don't have admin rights to the remote machine or if WMI is disabled on it.Also be sure you can ping/reach the machine specified in the $strComputer variable.edit:just some additional infohttp://www.autoitscript.com/forum/index.php?showtopic=44913&view=findpost&p=672678I checked it all. Still doesnt work.Checked firewalls and everything. Win XP domain environment. Link to comment Share on other sites More sharing options...
spudw2k Posted October 27, 2010 Share Posted October 27, 2010 I checked it all. Still doesnt work.Checked firewalls and everything. Win XP domain environment.Just for troubleshooting purposes, does it fail if you run the script locally on the box? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
RogFleming Posted October 30, 2010 Author Share Posted October 30, 2010 (edited) Updated option if the previous solution did not work for you: I found an issue if I want to execute a program on another system which needs to pass credentials to a network resource would fail. I needed to run the remote program Explicitly. Using PsExe.exe to launch wmic.exe on a remote system to start a process on that workstation,the network credentials are preserved. FYI the "c:\DTESCAN\" directory in the command is on the remote system, You could use PsExec to copy a file to execute instead. Also if you do not need to have credentials instead of the previous code you could do the following in you run command: run("wmic.exe /node:"&$targethost&" "&/node:"&$strComputer&" "&"PROCESS CALL Create"&" "&"'"&$Program&"'") Func RemoteExecutePsExec($ScanName, $strComputer,$sComputerName,$proc) Sleep(30) ShellExecute("c:\SysinternalsSuite\PsExec.exe","-d \\"&$strComputer&" "&"-u domain\username -p password wmic /node:"&$strComputer&" "&"PROCESS CALL Create"&" "&"'"&"c:\DTESCAN\"&$ScanName&" "&$sComputerName&" "&$Proc&"'","","Open",@SW_HIDE) Sleep(30) EndFunc Edited October 30, 2010 by RogFleming Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now