Jump to content

psexec and osql within autoit


Recommended Posts

Having Problems getting PSEXEC to execute within Autoit.

I can run the following on the remote machine with no problems:

ShellExecuteWait('C:\Program Files\Microsoft SQL Server\90\Tools\Binn\osql.exe', '-S DATA -d Logs -U sa -P password -n -Q "insert into t_File_Transfers (Tran_date,Process,Source_File,Destination_File,SF_Date,DF_Date,copy_flag) values('''& $systime &''',''Kronos Demographic Data to AS 400'',''AS400.TXT'',''AS400 - KRONOSHR'','''& $lstdate &''','''&$yyyymd1&''','''& $cpyflag&''')')

However if I try to run it from my local machine with PSEXEC it either runs but does not work or I get an "Unable to execute the external program" error. The variations I have tried to run are:

ShellExecuteWait('C:\Windows\psexec.exe', '\\zrk C:\ Program Files\Microsoft SQL Server\90\Tools\Binn\osql.exe -S DATA -d Logs -U sa -P password -n -Q "insert into t_File_Transfers (Tran_date,Process,Source_File,Destination_File,SF_Date,DF_Date,copy_flag) values('''& $systime &''',''Kronos Demographic Data to AS 400'',''AS400.TXT'',''AS400 - KRONOSHR'','''& $lstdate &''','''&$yyyymd1&''','''& $cpyflag&''')')

This runs but the osql command does not do the insert.

I have also tried:

RunWait(@Comspec & "/C" & 'C:\Windows\psexec.exe \\zrkdata osql.exe -S ZRKDATA -d Logs -U sa -P password -n -Q "insert into t_File_Transfers (Tran_date,Process,Source_File,Destination_File,SF_Date,DF_Date,copy_flag) values('''& $systime &''',''Kronos Demographic Data to AS 400'',''AS400.TXT'',''AS400 - KRONOSHR'','''& $lstdate &''','''&$yyyymd1&''','''& $cpyflag&''')')

This gives me the error mentioned above.

I figure there must be some small mistake in my syntax or something special required for PSEXEC that I don't know about. Can someone help?

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...