Page 1 of 1 1
Topic Options
#27180 - 2002-08-16 12:33 AM Copying a file
DrUltima Offline
Fresh Scripter

Registered: 2002-08-16
Posts: 21
Loc: Nashville, TN, USA
OK, this is my first post, so please be kind. [Smile]

For starters, here is the portion of my script that troubles me:
-----------
if $ClientType="Windows 2000 Professional"
if exists("C:\IP3.ico")=0
Copy "\\BSCApp01\NetLogon\IP3.ico" "C:\IP3.ico"
? "Copying IP Icon to local Workstation."
endif
if exists("%ALLUSERSPROFILE%\Desktop\Welcome to Interactive Practice.url")=0
Copy "\\BSC1App01\NetLogon\Welcome to Interactive Practice.url" "%ALLUSERSPROFILE%\Desktop\Welcome to Interactive Practice.url"
? "Copying Shortcut for the Interactive Practice to your Desktop."
endif
endif
--------------
The script actually copies the .url file as it is supposed to, and the text message saying the .ico file transmits, but it does not actually copy the .ico file to "c:\"

Any guideance for the newbie?

Top
#27181 - 2002-08-16 12:38 AM Re: Copying a file
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Hello and welcome to the board.

Please make sure your users have READ access to this location. You can also place the following code after the copy which will halt the script and allow you to check it.

? @ERROR
? @SERROR
GET $X

Top
#27182 - 2002-08-16 12:43 AM Re: Copying a file
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
First of all, if you post your code between CODE tags, then you preserve your formatting.

Secondly, you have a syntax error, it EXIST not EXISTS.

So, your improved script would look like this:
code:
if $ClientType="Windows 2000 Professional"
if not exist("C:\IP3.ico")
? "Copying IP Icon to local Workstation."
Copy "\\BSCApp01\NetLogon\IP3.ico" "C:\IP3.ico"
? ''+@ERROR+' - '+@SERROR
endif
if not exist("%ALLUSERSPROFILE%\Desktop\Welcome to Interactive Practice.url")
? "Copying Shortcut for the Interactive Practice to your Desktop."
Copy "\\BSC1App01\NetLogon\Welcome to Interactive Practice.url" "%ALLUSERSPROFILE%\Desktop\Welcome to Interactive Practice.url"
? ''+@ERROR+' - '+@SERROR
endif
endif

Finally, be aware that copying to the 'All Users' profile will most likely require administrative permissions. I would alos not copy the icon into the root directory but for example %WINDIR% or %WINDIR%\SYSTEM32

[ 16. August 2002, 00:45: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#27183 - 2002-08-16 07:59 PM Re: Copying a file
DrUltima Offline
Fresh Scripter

Registered: 2002-08-16
Posts: 21
Loc: Nashville, TN, USA
Thanks to you both! [Big Grin] I had a bad server name in the .ico path. I don't know how many times I looked at that and still did not see it. Error code returned it.

Sealeopard, you were correct about not wanting to place the icon file on root and about the permissions problem on the %ALLUSERSPROFILE%. I found command variable on TechNet in an article called Command Shell OVerview. I used it because I did not see a good way to get past defining the specific user directory. Now that I look again, I see a %USERPROFILE% (not sure how I missed it the first time), so I changed the code to:
code:
if $ClientType="Windows 2000 Professional"
if exist("%USERPROFILE%\IP3.ico")=0
? "Copying IP Icon to local Workstation."
Copy "\\BSC1App01\NetLogon\IP3.ico" "%USERPROFILE%\IP3.ico"
? ''+@ERROR+' - '+@SERROR
endif
if exist("%USERPROFILE%\Desktop\Welcome to Interactive Practice.url")=0
? "Copying Shortcut for the Interactive Practice to your Desktop."
Copy "\\BSC1App01\NetLogon\Welcome to Interactive Practice.url" "%USERPROFILE%\Desktop\Welcome to Interactive Practice.url"
? ''+@ERROR+' - '+@SERROR
endif
endif

That seemed to work very well. Any pointers appreciated. Thanks again.

Top
#27184 - 2002-08-16 08:56 PM Re: Copying a file
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Just so you know, the %USERPROFILE% vriable will point ot the current user. However, I would still copy it into the 'All Users' profile since everybody is getting the shortcut anyway.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.103 seconds in which 0.072 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org