Sign in to follow this  
Followers 0
AFXProdigy

Invoking a batch with runaswait

3 posts in this topic

Hello, i have this simple AutoIt script

the goal is to copy a shortcut to 'All Users' desktop with non Admin local users.

Local $sUserName = "Admin"
Local $sPassword = "*******"

Local $pid = RunAsWait($sUserName, @ComputerName, $sPassword, 0, @ComSpec & " /c " & "\\server\VOLXX\Users\Public\example.bat", @SystemDir)
ProcessWaitClose($pid)

and this simple batch file (example.bat)

@echo off
TITLE blabla
COLOR 2F

copy program.lnk "C:\Documents and Settings\All Users\Desktop\program.lnk" /Y

program.lnk is in the same folder as example.bat (\\server\VOLXX\Users\Public\) -already tried mapping to a drive, no help.-

the batch works fine, dunno why the script does not..

any help appreciated.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Under what credentials are you testing the batch file?

Anyway, the Local admin very likely does not have access to the share on the server thus fails to copy the file.

When you really need the local admin account then maybe first copying the file to a local drive like:

Local $sUserName = "Admin"
Local $sPassword = "*******"

FileCopy("\\server\VOLXX\Users\Public\program.lnk",@TempDir & "\program.lnk",1)
Local $pid = RunAsWait($sUserName, @ComputerName, $sPassword, 0, @ComSpec & ' /c copy "' & @TempDir & '\program.lnk" "C:\Documents and Settings\All Users\Desktop\program.lnk"', @SystemDir)

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks a lot, that do the trick :blink:

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  
Followers 0