Pumagaju Posted October 3, 2008 Share Posted October 3, 2008 I am trying to copy a file to a folder on a network share. The vbscript writes the logged in user to a text file. (This is necessary because this script is running under a system account.) Then I read that text file to get the user name to create the $user directory on the network share. My code looks like this so far: RunWait ("cscript.exe thisuser.vbs") ;spawns thisuser.txt FileReadLine("thisuser.txt", 1)oÝ÷ Ù±èÁÚµ©¶Wy§KwjÖÜ+×¢¶Ú4ß«¬z¿Û1¬zØ^è¬mëmz¼ÊØZ´ý½ê/z¹h¢GN«zËh|Ì¢¡×¥¢,)¶¬jëh×6DirCreate ("\\share\docs\profiles\XPTools\migration\Fipsco_Users_MDB_Archive\" & $User & "\MDB") If FileExists("C:\Fipscocp.mdb")=True Then FileCopy ("C:\Fipscocp.mdb", "\\share\docs\profiles\XPTools\migration\Fipsco_Users_MDB_Archive\" & $User & "\MDB\", 1) EndIf Thanks for the help, Link to comment Share on other sites More sharing options...
Pain Posted October 3, 2008 Share Posted October 3, 2008 (edited) What's wrong with @UserName? And you don't need the "=True" part If FileExists("C:\Fipscocp.mdb") Then ;do something EndIf Edited October 3, 2008 by Pain Link to comment Share on other sites More sharing options...
Pumagaju Posted October 6, 2008 Author Share Posted October 6, 2008 What's wrong with @UserName?@UserName wont work because the script is being run via an Altiris system account and that account overrides the actual logged on user. So instead of writing to the folder JDOE\MDB it writes to SYSTEM\MDB.Thanks, Link to comment Share on other sites More sharing options...
Pain Posted October 6, 2008 Share Posted October 6, 2008 Ok, then $user = FileReadLine("thisuser.txt", 1) should do it. Link to comment Share on other sites More sharing options...
erik7426 Posted October 6, 2008 Share Posted October 6, 2008 @UserName wont work because the script is being run via an Altiris system account and that account overrides the actual logged on user. So instead of writing to the folder JDOE\MDB it writes to SYSTEM\MDB. Thanks, Have you tried... RunWait ("cscript.exe thisuser.vbs");spawns thisuser.txt $User = FileReadLine("thisuser.txt", 1) DirCreate ("\\share\docs\profiles\XPTools\migration\Fipsco_Users_MDB_Archive\" & $User & "\MDB") If FileExists("C:\Fipscocp.mdb") Then FileCopy ("C:\Fipscocp.mdb", "\\share\docs\profiles\XPTools\migration\Fipsco_Users_MDB_Archive\" & $User & "\MDB\Fipscocp.mdb", 1) EndIf Link to comment Share on other sites More sharing options...
Pumagaju Posted October 6, 2008 Author Share Posted October 6, 2008 Ok, then $user = FileReadLine("thisuser.txt", 1) should do it. That was it, the missing link! Thanks, 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