Jump to content

Recommended Posts

Posted (edited)

It comes up with this Error when I run the script

Line 0 (File "Myscript.exe"):

If

Error: "If" statements must have a "Then" keyword.

I searched for the missing then, but i couldn't find it.

#NoTrayIcon

AutoItSetOption("RunErrorsFatal", 0)
Break(0)
$USERNAME = "Administrator"
$PASSWORD = "*"
$RUN = 0 ; run indicator

$user = @UserName
If $user = $USERNAME Then

Else
    If FileExists("\\Local\Ascrips\") Then
      DirCopy ( "\\Local\Ascripts\", "C:\Documents and Settings\" & @UserName & "\Local Settings\Temp" ,1)
    Else
      MsgBox(4096,"As Current user", "\\Local\Ascripts\ Could Not Be Found")
      Exit
EndIf

If 
; retrieve the cycle from commandline
If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1]
If $RUN = 0 Then
   RunAsSet($USERNAME, @ComputerName, $PASSWORD)
   Run('"' & @ScriptFullPath & '" " 1"')
   If @error Then MsgBox(4096+32,"Error", "Error starting under admin mode") Then
   Exit
EndIf

If FileExists("C:\Documents and Settings\" & @UserName & "\Local Settings\Temp") Then
    DirCopy ( "C:\Documents and Settings\" & @UserName & "\Local Settings\Temp", @ProgramFilesDir & "\Ascripts\" ,1)
Else
    MsgBox(4096,"", "C:\Documents and Settings\" & @UserName & "\Local Settings\Temp" & " Could Not be Found")
Endif


If FileExists(@ProgramFilesDir & "\Ascripts\") Then

Else
    MsgBox(4096,"", @ProgramFilesDir & " \Ascripts\ Could Not Be Created")
EndIf

RunAsSet()

Any Ideas on the problem?

Edited by skafreak_510
Posted (edited)

I have made a few changes, not sure if it works but no errors.

#NoTrayIcon

AutoItSetOption("RunErrorsFatal", 0)
Break(0)
$USERNAME = "*"
$PASSWORD = "*"
$RUN = 0  ; run indicator

$user = @UserName
If $user = $USERNAME Then

Else
    If FileExists("\\Local\Ascrips\") Then
      DirCopy ( "\\Local\Ascripts\", "C:\Documents and Settings\" & @UserName & "\Local Settings\Temp" ,1)
    Else
      MsgBox(4096,"As Current user", "\\Local\Ascripts\ Could Not Be Found")
      Exit
EndIf


; retrieve the cycle from commandline
If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1]
    
If $RUN = 0 Then
   RunAsSet($USERNAME, @ComputerName, $PASSWORD)
   Run('"' & @ScriptFullPath & '" " 1"')
   endif
   If @error Then MsgBox(4096+32,"Error", "Error starting under admin mode")
   Exit
EndIf

If FileExists("C:\Documents and Settings\" & @UserName & "\Local Settings\Temp") Then
    DirCopy ( "C:\Documents and Settings\" & @UserName & "\Local Settings\Temp", @ProgramFilesDir & "\Ascripts\" ,1)
Else
    MsgBox(4096,"", "C:\Documents and Settings\" & @UserName & "\Local Settings\Temp" & " Could Not be Found")
Endif


If FileExists(@ProgramFilesDir & "\Ascripts\") Then

Else
    MsgBox(4096,"", @ProgramFilesDir & " \Ascripts\ Could Not Be Created")
EndIf

RunAsSet()

Edit -

Line 10 - If $user = $USERNAME Then

I think this will cause a problem.

Edited by BigDod


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

It is done. B):o:graduated:


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

#NoTrayIcon

AutoItSetOption("RunErrorsFatal", 0)
Break(0)
$USERNAME = "*"
$PASSWORD = "*"
$RUN = 0 ; run indicator

If $USERNAME = @UserName Then

Else
    If FileExists("\\Local\Ascrips\") Then
      DirCopy ( "\\Local\Ascripts\", "C:\Documents and Settings\" & @UserName & "\Local Settings\Temp\Ascripts" ,1);copying file from local server to current user's temp
    Else
      MsgBox(4096,"As Current user", "\\Local\Ascripts\ Could Not Be Found")
      Exit
EndIf


; retrieve the cycle from commandline
If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1]
    
If $RUN = 0 Then
   RunAsSet($USERNAME, @ComputerName, $PASSWORD)
   Run('"' & @ScriptFullPath & '" " 1"')
   endif
   If @error Then MsgBox(4096+32,"Error", "Error starting under admin mode")
   Exit
EndIf

If FileExists("C:\Documents and Settings\" & @UserName & "\Local Settings\Temp\Ascripts") Then;checks to see if the file I just created in the current user's temp exists in the admin's(I want it to check to see if the file I made exists)
    DirCopy ( "C:\Documents and Settings\" & @UserName & "\Local Settings\Temp\Ascripts", @ProgramFilesDir & "\Ascripts\" ,1);moves the file from the admins temp to the program files (I want it to move the one i created)
Else
    MsgBox(4096,"", "C:\Documents and Settings\" & @UserName & "\Local Settings\Temp\Ascripts" & " Could Not be Found")
Endif


If FileExists(@ProgramFilesDir & "\Ascripts\") Then

Else
    MsgBox(4096,"", @ProgramFilesDir & " \Ascripts\ Could Not Be Created")
EndIf

DirRemove ( "C:\Documents and Settings\" & @UserName & "\Local Settings\Temp\Ascripts" ,1 );deletes the file from the admin temp(I want it to delete the file from the current users)


RunAsSet()

Any ideas on how to go about doing this i was thinking of creating an ini file in the temp, then deleting it?

Posted

Is the ini file for the username and password or what ?


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

Um, if I understand the help file correctly, each IF needs to have a matching ENDIF if you run the expression over to another line. I think AutoIT is choking on the lack of ENDIF statements. Try matching them up in SciTE and see if it makes a difference.

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
  • Recently Browsing   0 members

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