Jump to content

RunasSet - Error message


Recommended Posts

Hi,

Newbie on his second project...Please don't hurt me.

Have created this simple script to copy a file off of a shared folder to the local machine. Works fine under administrator. Read the help and inserted the RunAsSet command. Here is the code:

RunAsSet("Administrator", @ComputerName, "adminpassword")

FileCopy("\\commander\cafe\update\update.txt","c:\Windows\CB\update.txt")

When I replaced the adminpassword with the password to be used and also the ComputerName it gives me an error which is: Error: Unknown Macro above that it has the line in question.

If I don't insert that info the script runs but not under the user I need it to. It does under administrator.

I need to understand the syntax. Do I replace those feilds or leave them and append them elsewhere?

Could someone please give me a heads up?????

Thanks for help...I have looked through formus but no bells ringing yet.

Mike

Link to comment
Share on other sites

  • Developers

Remarks

This function allows subsequent Run and RunWait functions to run as a different user (e.g. Administrator).

Thus doesn't work on FileCopy.

A restart of the script could do the job for you (see below) or use the DOS copy with a RunWait().

; AutoIt Version: 3.0
; Language:    English
; Platform:    Win9x/NT/XP
; Author:        jos van der Zande
;
AutoItSetOption("RunErrorsFatal", 0) 
AutoItSetOption("TrayIconHide", 1) 
Break(0)
$USERNAME = "Administrator"
$PASSWORD = "Secret"
$RUN = 0      ; run indicator 
; 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")
   Exit
EndIf
; commands go here that require Administrator rights

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

Can I ask then is this in help and how does one nut this thing out using help...Any hints on what I should have looked at...

Or is all this just going to become apparent over time?

Cheers Again

Mike

Thus doesn't work on FileCopy.

A restart of the script could do the job for you (see below) or use the DOS copy with a RunWait().

; AutoIt Version: 3.0
; Language:    English
; Platform:    Win9x/NT/XP
; Author:        jos van der Zande
;
AutoItSetOption("RunErrorsFatal", 0) 
AutoItSetOption("TrayIconHide", 1) 
Break(0)
$USERNAME = "Administrator"
$PASSWORD = "Secret"
$RUN = 0     ; run indicator 
; 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")
   Exit
EndIf
; commands go here that require Administrator rights
Link to comment
Share on other sites

While it's kind of natural to do so, it does require an assumption that RunAsSet credentials would apply to other functions besides Run and RunWait; the documentation for RunAsSet only mentions Run and RunWait. :P

Been there, assumed that.

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

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...