GTunney Posted February 8, 2011 Share Posted February 8, 2011 I use AutoIT to roll out mass software installations. I'm currently working on a script at the moment which copies files from a server to the local c drive and then copies a shortcut to the desktop. The files copy to the c drive no problem but it will not copy the shortcut. I have tried to use the RunAs command for the whole script but it doesnt appear to be working. any help would be appreciated. Username, password and domain have been removed for security reasons. ; Fill in the username and password appropriate for your system. Local $sUserName = "Username" Local $sPassword = "Password" Local $sDomain = "Domain.net" Local $sShare = "\\helpdeskdev01\software" Local $sLocation = $sShare & "\optim\" ;Copy files to local drive and shortcut. DirCreate("C:\Acucorp\Acucbl722\AcuGT\bin") FileCopy("\\helpdeskdev01\software\optim\files\*.*","C:\Acucorp\Acucbl722\AcuGT\bin",1) FileCopy("C:\Acucorp\Acucbl722\AcuGT\bin\Optim Live System.lnk","C:\Documents and Settings\All Users\Desktop",1) Link to comment Share on other sites More sharing options...
Triblade Posted February 8, 2011 Share Posted February 8, 2011 Just to save a lot of time: why not via Group Policies? My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
GTunney Posted February 8, 2011 Author Share Posted February 8, 2011 (edited) Just to save a lot of time: why not via Group Policies?Because the business has over 5000 users and it's not needed on all the machines, just about 200 in a certain building.Not to mention our infrastructure team is pretty erm....lazy! Edited February 8, 2011 by GTunney Link to comment Share on other sites More sharing options...
Triblade Posted February 8, 2011 Share Posted February 8, 2011 Not to mention our infrastructure team is pretty erm....lazy!Know the feeling In the AutoIt help file FileCopy is done with a trailing slash in the destination path. Try that please. My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
GTunney Posted February 8, 2011 Author Share Posted February 8, 2011 Know the feeling In the AutoIt help file FileCopy is done with a trailing slash in the destination path. Try that please.It's not the file path i'm having trouble with as the files do copy over. It's just the shortcut at the end which will not copy over.As the All Users folder only has domain admins access. Which is why i wanted to runas which ever user is specified at the top. Link to comment Share on other sites More sharing options...
Triblade Posted February 8, 2011 Share Posted February 8, 2011 Odd, and if you use _ instead of spaces in the shortcut? (just to try things out) My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
Juvigy Posted February 8, 2011 Share Posted February 8, 2011 Check out the RUNAS examples. You can RUNAS your entire script as a domain user too. Link to comment Share on other sites More sharing options...
GTunney Posted February 8, 2011 Author Share Posted February 8, 2011 Check out the RUNAS examples. You can RUNAS your entire script as a domain user too.It's deffo a file permission as it works fine when an admin runs it.Thats what im trying to acheive juvigy and have looked at examples but can't figure it out. Link to comment Share on other sites More sharing options...
Juvigy Posted February 9, 2011 Share Posted February 9, 2011 Try this: Local $sUserName = "Username" Local $sPassword = "Password" Local $sDomain = "Domain.net" RunAs($sUserName , $sDomain , $sPassword ,0,@ScriptName,@ScriptDir) Link to comment Share on other sites More sharing options...
GTunney Posted February 9, 2011 Author Share Posted February 9, 2011 (edited) Try this: Local $sUserName = "Username" Local $sPassword = "Password" Local $sDomain = "Domain.net" RunAs($sUserName , $sDomain , $sPassword ,0,@ScriptName,@ScriptDir) I've given that a go but just get error messages. EDIT: My fault i left some old code in there, it's been tested and working perfectly. Thanks for all your help Edited February 9, 2011 by GTunney Link to comment Share on other sites More sharing options...
GTunney Posted February 9, 2011 Author Share Posted February 9, 2011 Ok got another slight problem, i've added a Installation Complete box at the very end and this box keeps opening like 10 times. I've checked the sessions as well and to copy the files over it's opening 10 sessions and running multiple instances of the auto it. ; Fill in the username and password appropriate for your system. Local $sUserName = "username" Local $sPassword = "password" Local $sDomain = "domain" RunAs($sUserName , $sDomain , $sPassword ,2,@ScriptName,@ScriptDir) ;Copy files to local drive and shortcut. DirCreate("C:\Acucorp\Acucbl722\AcuGT\bin") FileCopy("\\helpdeskdev01\software\optim\files\*.*","C:\Acucorp\Acucbl722\AcuGT\bin",1) FileCopy("C:\Acucorp\Acucbl722\AcuGT\bin\Optim Live System.lnk","C:\Documents and Settings\All Users\Desktop",1) ; Show a message. MsgBox(0, "Optim Live System Installed", "Any issues please contact the BIS Service desk on 0191 247 3999") Link to comment Share on other sites More sharing options...
GTunney Posted February 11, 2011 Author Share Posted February 11, 2011 Any suggestions could really do with getting this resolved? Link to comment Share on other sites More sharing options...
Juvigy Posted February 11, 2011 Share Posted February 11, 2011 You execute only the above code and you get 10 msgboxes ? Link to comment Share on other sites More sharing options...
GTunney Posted February 11, 2011 Author Share Posted February 11, 2011 Yes correct, also multiple instanced of the auto it script appear to be running. If i look in the task bar there is about 10 auto it icons load up then eventually close. Link to comment Share on other sites More sharing options...
Juvigy Posted February 11, 2011 Share Posted February 11, 2011 I cant test it but i think it does it because it runas every file copy process separately. FileCopy("\\helpdeskdev01\software\optim\files\*.*","C:\Acucorp\Acucbl722\AcuGT\bin",1) Change this to a only one file copy to test it. Link to comment Share on other sites More sharing options...
GTunney Posted February 14, 2011 Author Share Posted February 14, 2011 (edited) Ok it was the RunAs command that was causing it to run numerous times even with 1 file it would run numerous times. I have removed the runas command and instead of copying the shortcut to all users desktop i am just trying to copy it to the logged on users desktop but having some trouble with the variable. I have tried both @UserName and %UserName% but if i enter the username of the logged on user it works fine. ;Copy files to local drive and shortcut. DirCreate("C:\Acucorp\Acucbl722\AcuGT\bin") FileCopy("\\helpdeskdev01\software\optim\files\*.*","C:\Acucorp\Acucbl722\AcuGT\bin",1) FileCopy("C:\Acucorp\Acucbl722\AcuGT\bin\Optim Live System.lnk","C:\Documents and Settings\@UserName\Desktop",1) ; Show a message. MsgBox(0, "Optim Live System Installed", "Any issues please contact the BIS Service desk on 0191 247 3999") Edited February 14, 2011 by GTunney Link to comment Share on other sites More sharing options...
Juvigy Posted February 14, 2011 Share Posted February 14, 2011 You need to change it a little bit like this: FileCopy("C:\Acucorp\Acucbl722\AcuGT\bin\Optim Live System.lnk","C:\Documents and Settings\"&@UserName&"\Desktop",1) Link to comment Share on other sites More sharing options...
GTunney Posted February 14, 2011 Author Share Posted February 14, 2011 Beautiful works a treat, knew it would be something simple. Also anyway to ensure it kills the users session once the files have been copied over? Thanks for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now