Jump to content

psexec convert to Autoit - (Moved)


Recommended Posts

I have this psexec command working fine 

Local $sMachine = InputBox("Input PC name", "Enter Computer Name")

psexec \\$sMachine -u $sDomain\$sUserName -p $sPassword  \\NetworkFLD\FILENAME.cmd > C:\Temp\TT\My.log
 

I wanted to converted to AutoIT script

Cloud you help, please !?

 

Link to comment
Share on other sites

  • Developers

Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states:

Quote

Share your cool AutoIt scripts, UDFs and applications with others.


Do not post general support questions here, instead use the AutoIt Help and Support forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

@bmy007ro look at shellexecute in the help file; it is a pretty straight-forward conversion. As an example, here is one of the PSExec scripts I have used in the past to give you an idea of syntax:

$asset = InputBox("RegExport", "Enter the asset tag.")

DirCreate('\\' & $asset & '\C$\MyReg')
ShellExecute("C:\psexec.exe", '-s \\' & $asset & ' REG EXPORT HKLM\Software\ODBC C:\ODBC.reg', "", "", @SW_HIDE)

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

And PSExec has parameters for doing just that, just plug them into your ShellExecute statement.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I try  this but nothing....any idea?

Local $sUserName = "aaaaa"
Local $sPassword = "bbbbb"
Local $sDomain = "yyz"


Local $s_Machine = InputBox("Input PC name", "Enter Computer Name")

ShellExecute("c:\Temp\TT\PsExec.exe", '-s \\' & $s_Machine & ' -u' & $sUserName & ' -p' & $sPassword & ' \\NET\Files\FILENAME.cmd > C:\Temp\TT\My.log', "", "", @SW_HIDE)

Link to comment
Share on other sites

I would rather suggest using the command prompt then executing the exe.
As far as I have tested you cant run PsExec straight as it is a command line program. 

NOTE: When posting code, make sure you click on the <> and paste your code in.
 

Local $sUserName = "aaaaa"
Local $sPassword = "bbbbb"
Local $sDomain = "yyz"

Local $s_Machine = InputBox("Input PC name", "Enter Computer Name")
Run(@ComSpec & " /k " & 'c:\Temp\TT\PsExec.exe -s \\ ' & $s_Machine &  ' -u '& $sUserName & '-p ' & $sPassword & ' \\NET\File\FILENAME.bat > C:\Temp\data.log', "", @SW_SHOW)

 

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Link to comment
Share on other sites

  • Moderators
5 hours ago, Skeletor said:

As far as I have tested you cant run PsExec straight as it is a command line program. 

That is untrue, as I do so often both in AutoIt and PowerShell

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

You should be able to call psexec.exe directly using Run or ShellExecute.  The tricky parts may be if you want to automate StdIn or StdOut.  There are functions for those too.  Check out the examples in the help file.  

StdinWrite()
StdoutRead()

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...