Sign in to follow this  
Followers 0
Pumagaju

Help writing to a network share

6 posts in this topic

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,

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What's wrong with @UserName?

And you don't need the "=True" part

If FileExists("C:\Fipscocp.mdb") Then
;do something
EndIf
Edited by Pain

Share this post


Link to post
Share on other sites

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,

Share this post


Link to post
Share on other sites

Ok, then

$user = FileReadLine("thisuser.txt", 1)
should do it. :P

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites

Ok, then

$user = FileReadLine("thisuser.txt", 1)
should do it. :P
That was it, the missing link!

Thanks,

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