Avatar of nw_mr2
nw_mr2

asked on 

Newbie to scripting - %USERPROFILE% not working?

I'm VERY new to VBscripting and am just learning by browsing the internet. I'm trying to have a script that will check for a file on the client computer, and copy it from the our server if necessary. This file enables client communication for a help desk program we use.

Now if I change the paths and run this from a client machine, it works fine. But trying to run it from the server gives me:

---------------------------------------------------
Windows Script Host
Script: \\(servername)\Shared\ncc\scripts\ARScript.vbs
Line: 12
Char: 1
Error: Path not found
Code: 800A004C
Source: Microsoft VBScript runtime error
-----------------------------------------------------

I'm lost, as another script I have doing the SAME thing works fine, and all the file paths are correct, permissions are set, etc. Any thoughts are very much appreciated.
local_path = "%USERPROFILE%\Application Data\AR System\HOME\AR" 
server_path = "\\(servername)\shared\NCC\Scripts\AR"
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
'add user profile to local_path
 
 
'check if file exists
If objFSO.FileExists(local_path) = False Then
'copy file
objFSO.CopyFile server_path, local_path
End if

Open in new window

VB Script

Avatar of undefined
Last Comment
Serge Fournier

8/22/2022 - Mon