Jump to content
Sign in to follow this  
abhi

Win 2003 vs Win 2000

Recommended Posts

abhi

All,

I am calling the following code from a service

#include <Constants.au3>
#include <Date.au3>

Opt("RunErrorsFatal", 0)

Global $var1 = $CmdLine[1]  ;user

Global $var2 = $CmdLine[2]  ;domain

Global $var3 = $CmdLine[3]  ;password

Global $var4 = $CmdLine[4]  ;batch file to execute

Global $var5 = $CmdLine[5]  ;log file 

Global $workDir = $CmdLine[6]   ;working dir

Global $logFile = FileOpen($var5, 2)

RunAsSet($var1,$var2,$var3)

FileWrite($logFile,  "Launching commands...." & _Now() & @CRLF)
FileClose($logFile)

;$retVal = RunWait(@ComSpec & " /c" & $var4 & " >> " & $var5 &  " 2>&1")
$retVal = RunWait($var4 & " >> " & $var5 &  " 2>&1",$workDir)

if @error Then
    $logFile = FileOpen($var5, 1)
    FileWrite($logFile,  "WINSSHELLERR: Error executing script. Please check if the User Id - " & $var1 & ", Domain - " &  $var2 & "  and Password are valid.")
    FileClose($logFile)
    Exit 1
EndIf

If $retVal <> 0 Then
    $logFile = FileOpen($var5, 1)
    FileWrite($logFile,  "WINSSHELLERR: Error executing script.")
    FileClose($logFile)
    Exit 1
EndIf

$logFile = FileOpen($var5, 1)
FileWrite($logFile,  "Finished executing commands.." & _Now() & @CRLF)
FileClose($logFile)

Everything works fine when I call the autoit executable on Win 2K machine. However on a Windows 2003 server, the script consitently errors out throwing the following app error

"WINSSHELLERR: Error executing script. Please check if the User Id - " & $var1 & ", Domain - " & $var2 & " and Password are valid."

I have made sure that the user credentials I am using are correct. What's baffling is the fact that if I call the auto it executable from commandline it works as per design.

I am unable to figure out what makes the script reject the user credentials on a Win 2003 server. Are there any ways to Trace the executable that could help me debug the issue. Are there any issues with autoit and Win 2003 that I am overlooking ?

Thanks

Share this post


Link to post
Share on other sites
herewasplato

I do not have Win 2003 server, so I cannot help much other than to give you a free bump in the forum at a time when a lot of members are on line :-)


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
Kip

I have 2003 server Basic, and it gives an error to. BUT if you remove: ,$workDir from

$retVal = RunWait($var4 & " >> " & $var5 &  " 2>&1",$workDir)

Then it works fine!

Now i get:

Launching commands....3-6-2007 20:47:01

C:\Documents and Settings\Administrator\Desktop>ShutDown -i 
Finished executing commands..3-6-2007 20:47:02
Edited by kip

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.