Jump to content

Recommended Posts

Posted

Can someone tell me what is wrong with my syntax here ?

RunAs("xxx", "xxxxxx", "xxxxxxx", 0, FileCopy & @LogonServer & "\netlogon\hosts_test c:\windows\system32\drivers\etc")
Posted

What are you trying to do?

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

I would try:

RunAs("xxx", "xxxxxx", "xxxxxxx", 0, "FileCopy " & @LogonServer & "netlogonhosts_test C:\Windows\System32\driversetc")

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

BTW: The help file says:

"The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks)."

It looks like you are trying to run a single AutoIt function (FileCopy) as another user - this is not possible.

Edited by water

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

  On 5/18/2012 at 9:53 AM, 'water said:

BTW: The help file says:

"The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks)."

It looks like you are trying to run a single AutoIt function (FileCopy) as another user - this is not possible.

It's how I interpreted MattX's post too.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

  On 5/18/2012 at 9:46 AM, 'water said:

I would try:

RunAs("xxx", "xxxxxx", "xxxxxxx", 0, "FileCopy " & @LogonServer & "netlogonhosts_test C:\Windows\System32\driversetc")

Don't get the syntax error now but file refuses to copy for some reason....
Posted

If you check the return value and @error you'll see that the "program" you try to execute wasn't found.

$result = RunAs("xxx", "xxxxxx", "xxxxxxx", 0, "FileCopy " & @LogonServer & "netlogonhosts_test C:\Windows\System32\driversetc")
MsgBox(16, "Error", "Return value: " & $result & ", @error: " & @error)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

  On 5/18/2012 at 9:55 AM, 'guinness said:

It's how I interpreted MattX's post too.

Hi guinness,

that's fine but how does this help the OP solve his problem ;)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

I was waiting for him to reply to my second post to obtain a reason as to what he was trying to do, before second guessing. MattX, look at /AutoIt3ExecuteLine and use RunAs.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

  On 5/18/2012 at 9:53 AM, 'water said:

BTW: The help file says:

"The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks)."

It looks like you are trying to run a single AutoIt function (FileCopy) as another user - this is not possible.

Reason I tried that is because the xcopy command I put in also refuses - a bit daft as the del does work !!

Here you go - yet again something so simple won't work 'cos the file copy just point blankly refuses. I've also tried witout the and also %netlogon%

SplashTextOn("Flushing DNS","Flushing DNS - please wait","300","50","-1","-1","","","")
sleep(3000)
RunAs("xxx", "xxx", "xxx", 0, @ComSpec & " /c " & "ipconfig /flushdns")
SplashOff()
RunAs("xxx", "xxx", "xxx", 0, @ComSpec & " /c " & "ipconfig /registerdns")
SplashTextOn("Registering DNS","Registering DNS - please wait","300","50","-1","-1","","","")
sleep(3000)
SplashOff()
SplashTextOn("HOSTS File","Deleting and copying over new HOSTS File - please wait","300","150","-1","-1","","","")
sleep(3000)
RunAs("xxx", "xxx", "xxx", 0, @ComSpec & " /c " & "del C:\Windows\System32\driversetchosts")
RunAs("xxx", "xxx", "xxx", 0, @ComSpec & " /c " & "xcopy %logonserver%netlogonhosts_test C:\Windows\System32\driversetc /y")
SplashOff()
MsgBox(64,"DNS & HOSTS SCRIPT","DNS Flush / Register & Hosts replacement complete.")
Posted

This will only work in a cmd window if you add the extra quotes:

C:>xcopy "%logonserver%netlogonhosts_test" "C:\Windows\System32\driversetc"

How can I get those extra quotes in the relevant line in the script ?

Posted

To get a quote in a quote delimited string you need to double the quote.

ConsoleWrite(" This is a string with a quote in it: "" " & @CRLF)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Won't compile now - with this:

RunAs("xxx", "xxx", "xxx", 0, @ComSpec & " /c " & "xcopy ""%logonserver%netlogonhosts_test"" ""C:\Windows\System32\driversetc"")

Posted

Add a quote at the end: etc""")

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Thanks - as soon as I moved the file from the netlogon to a folder on a different server it copied over !! [ permissions....AAggghhh ]- been caught out on that quite a few times.....Thanks for your help.

Posted

Glad the problem could be solved ;)

My UDFs and Tutorials:

  Reveal hidden contents

 

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
×
×
  • Create New...