Jump to content

Invoking a batch with runaswait


Recommended Posts

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.

Link to comment
Share on other sites

  • Developers

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

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

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