Kathy
(Getting the hang of it)
2002-09-12 10:50 PM
Copying Shortcut

I have a really simple script that I am trying to run. Everything runs fine except the copy command when I login. If I run kix32 kathy at a command line the shortcut copies to the desktop.
What am I doing wrong?

;This is a test kixtart script created for Marshall users on Win98
; Created 9/12/2001 - Kathy
if ingroup("TX Mapcon Test")
? "You are a Member of Mapcon Group"
Use O: /delete /PERSISTENT
USE O: "\\Server\Apps\Apps"/PERSISTENT
COPY "//Server\netlogon\shortcuts\mapcontest.lnk" "C:\windows\desktop"
? "You should have a shortcut on your desktop that looks like a toolbox"
ELSE
?"Notify Kathy that your script is not working correctly"
ENDIF


LonkeroAdministrator
(KiX Master Guru)
2002-09-12 10:55 PM
Re: Copying Shortcut

first note, pretty old script you got there... from last year... [Big Grin]

anyway, your copy is wrong and not even preferred:
COPY "//Server\netlogon\shortcuts\mapcontest.lnk" "C:\windows\desktop"

should be:
COPY "\\Server\netlogon\shortcuts\mapcontest.lnk" "C:\windows\desktop"

also, the desktop location is not always that.
meaning you should read the value from registry...

and most importantly, you should not traffic only one logonserver, but the one user is logging on:
COPY @ldrive+"\shortcuts\mapcontest.lnk" "C:\windows\desktop"


Kathy
(Getting the hang of it)
2002-09-13 02:49 PM
Re: Copying Shortcut

Hey give me a break here. I am a Netware Certified person that has been thrust into the MS world against my will. Netware wins HANDS DOWN. haha!

Radimus
(KiX Supporter)
2002-09-13 03:00 PM
Re: Copying Shortcut

have you see the stock prices lately [Smile]

There are a number of utilities (functions) to create shortcuts in the UDF forum.


Les
(KiX Master)
2002-09-13 03:01 PM
Re: Copying Shortcut

Oh dear... don't go there. We have a lot of SAD (SysAdmin by Decree) people on this board. Deal with it.

Lonkero makes some good points but unlikely that is the solution. If your script works after logon but not during then you have other issues.

I suggest you try debugging the script to see where it fails.


Kathy
(Getting the hang of it)
2002-09-13 04:41 PM
Re: Copying Shortcut

I was just joking. I was a COBOL programmer in my previous life. I will look on the forum for better examples of simple login scrips. All I need is a drive mapped and a shortcut put on the desktop. Thanks for all your help!

Sealeopard
(KiX Master)
2002-09-13 06:17 PM
Re: Copying Shortcut

If you put a
code:
? ''+@ERROR+' - '+@SERROR

after your copy command, you will get the error message generated for that copy command. If the copy is successful, error will be '0'.

You might also want to make sure to run the login script synchronously, see W2k/XP - Keep the Window visible on login?


Kathy
(Getting the hang of it)
2002-09-13 08:40 PM
Re: Copying Shortcut

Why is it?- so easy from a command prompt to copy a shortcut to the desktop and within Kixtart so hard? I get a drive mapped fine. (We have a program that all it needs is a drive mapping and a shorcut.) But copying a shortcut I cannot get to work.

Kixtart v4.11
Users have a Netware 5.1 and a Win2k login script - this is temporary Netware is being phased out.
Users have win98.
Anyone have a script that is copying a shortcut that is working I can look at?
Thanks for help.


Sealeopard
(KiX Master)
2002-09-13 09:01 PM
Re: Copying Shortcut

It is different to copy a shortcut when you're already logged on and during the logon phase. please read the following FAQs:
Copy a shortcut to the Desktop, Start Menu, etc.
Sequence of events during logon

You should really put some error checks into your code to figure out what exactly is going wrong, for example check that the directories and files actually exist.

If you have a working command lne to copy the shortcut, why don't you try that one from within the login script and see whether it succeeds. I suspect that your command line copy will fail, too.

Are you using profiles under Windows 9x? you need to establish the exact location of the desktop folder before copying, it does not ahve top be at c:\windwos\desktop.


Kathy
(Getting the hang of it)
2002-09-13 09:04 PM
Re: Copying Shortcut

JENS:
The FAQs are where? If I type the copy command at a command line prompt, it works. Just not within the kixtart script. I am new to all of this.


Howard Bullock
(KiX Supporter)
2002-09-13 09:05 PM
Re: Copying Shortcut

they are links, just click on them.

Kathy
(Getting the hang of it)
2002-09-13 09:56 PM
Re: Copying Shortcut

Ok with the help of some of the links I think I have narrowed the problem down. I think Win98 is loading the desktop before the script has time to put the shortcut on the desktop.

The reason I think this is that if I login as usual, I get no icon on the desktop. If I go to a command line and type kix32 test.kix. The icon appears. I read on a link to change the registry value for winlogon to 1 this is suppose to tell the system to run all the scripts before presenting the win98 desktop but I tried this and it did not work. Anyone else have an idea? I am having so much fun with this - I love this forum.
Kixtart v4.11
Servers Netware 5.1 and Win2K
Users running Netware and Win2k logon script
Users have Win98 workstations


Les
(KiX Master)
2002-09-13 10:11 PM
Re: Copying Shortcut

Kathy,
You're on the right track... just maybe going in the wrong direction. The issue is likely that the desktop has not yet been set whilst still in the logon. This is a well known issue with Wintendos. In fact, I have an FAQ on it.

Topic: Sequence of events during logon

Pay attention to the bit about RunOnce and then search for that on the board.

Yeah Jens, you said it first... but sometimes it take more than one person to say it. [Wink]

[ 13. September 2002, 22:16: Message edited by: LLigetfa ]


Kathy
(Getting the hang of it)
2002-09-13 10:13 PM
Re: Copying Shortcut

Another test, I ran the kix32 test.kix /debug and used F* to step each line in the script. It ran fine. Just one more thing to help backup my theory that all the things running when a user logs in is keeping the script from running correctly. Anyone else have this problem and know of a fix? Thanks - have a great weekend it is 94 degrees F here in Texas.

Kathy
(Getting the hang of it)
2002-09-13 10:18 PM
Re: Copying Shortcut

Next question.
How can I get a win98 PC to wait until the logon scripts finish before loading the desktop?

I tried the setting winlogon set to 1. Did not help.


Les
(KiX Master)
2002-09-13 10:21 PM
Re: Copying Shortcut

Many before you have tried... RunOnce RunOnce

GRF
(Fresh Scripter)
2002-09-13 10:23 PM
Re: Copying Shortcut

I use the following and have never had it not work.

code:
 $Icon98 = "C:\windows\DESKTOP\ESI.PIF"
if exist ($icon98) = 0 copy "q:\esi98.pif" "C:\windows\desktop\ESI.pif"
endif

Hope it helps,


Kathy
(Getting the hang of it)
2002-09-13 10:29 PM
Re: Copying Shortcut

My ignorance is showing. Aren't .pif files old windows files.

What does your code do? I need explanations.


GRF
(Fresh Scripter)
2002-09-13 11:11 PM
Re: Copying Shortcut

It's just a pointer to another executable. You should be able to replace the .pif with whatever extension (in your case .lnk) you want.

Good luck,


Radimus
(KiX Supporter)
2002-09-13 11:11 PM
Re: Copying Shortcut

fdisk will fix most of this.

Jack Lothian
(MM club member)
2002-09-13 11:18 PM
Re: Copying Shortcut

I believe Les is giving you a cryptic hint. I think the problem may be the current user hive in the registry & the current user profile does not exist in Win9x until after logon fully completes. The Runonce key runs after logon completes not during the logon script. So create a second bat file that does the copying then poke the name & location of this second bat file into runonce key in the registry. It will execute when the user profile is active.

What type of profiles/polocies are you using?

[ 13. September 2002, 23:24: Message edited by: Jack Lothian ]


GRF
(Fresh Scripter)
2002-09-13 11:19 PM
Re: Copying Shortcut

Sorry, here is more. $icon98 is a variable that equals your file name. If exist = 0 means it isn't there, so it copies it. My code didn't quite post properly.
code:
$Icon98 = "C:\windows\DESKTOP\ESI.PIF"
if exist ($icon98) = 0
copy "q:\esi98.pif" "C:\windows\desktop\ESI.pif"
endif

GF


Sealeopard
(KiX Master)
2002-09-13 11:36 PM
Re: Copying Shortcut

Just to be on the save side, put the call to the batch file that calls the KiXtart script with the link copy routine into HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce and NOT into the HKEY_CURRENT_USER subkey! This guarantee execution of the RunOnce independend of whether the HKEY_CURRENT_USER profile is already loaded or not.

Kathy
(Getting the hang of it)
2002-09-16 02:40 PM
Re: Copying Shortcut

So on the value in the registery I can put:
\\server\netlgon\short.bat (that has the copy command in the file)?

Thanks for all your help.


Sealeopard
(KiX Master)
2002-09-16 04:19 PM
Re: Copying Shortcut

Yes, but nost likely the folder is called NETLOGON and not NETLGON, however, that might be a type.

Kathy
(Getting the hang of it)
2002-09-16 04:48 PM
Re: Copying Shortcut

Not to good a typist. That worked on my local Win98 PC. Thanks... Now is there a way I can use INGROUP and change the settings on user's registries if they are in the group that needs the icon or is this way to difficult for a beginner like me?

Sealeopard
(KiX Master)
2002-09-16 04:52 PM
Re: Copying Shortcut

Just use a succession of IF INGROUP to make appropriate changes
code:
IF INGROUP(Group A')
; do stuff
ENDIF
IF INGROUP('Group B')
; do other sutff
ENDIF

Alternatively, if the groups are mutually exclusive, then you cna also use SELECT-CASE-ENDSELECT like
code:
SELECT
CASE INGROUP('Group A')
; do stuff
CASE INGROUP('Group B')
; do other stuff
CASE 1
; do stuff for members of neither Group A nor Group B
ENDSELECT



Kathy
(Getting the hang of it)
2002-09-16 07:36 PM
Re: Copying Shortcut

Do you have a copy of a script that will show me how to add to the RUNONCE registry settings to the Win98 PCs?

LonkeroAdministrator
(KiX Master Guru)
2002-09-16 07:44 PM
Re: Copying Shortcut

something like:
writevalue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce","run_me","yourcopy_command","REG_SZ")

[ 16. September 2002, 19:45: Message edited by: Lonkero ]


Sealeopard
(KiX Master)
2002-09-16 07:49 PM
Re: Copying Shortcut

For Windows 9x:
code:
$rc=writevalue('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce','AppName','AppToRun','REG_SZ')



LonkeroAdministrator
(KiX Master Guru)
2002-09-16 07:51 PM
Re: Copying Shortcut

jens, aint that just the same? [Roll Eyes]

Sealeopard
(KiX Master)
2002-09-16 08:08 PM
Re: Copying Shortcut

I lagged in posting while trying to do two things at the same time, namely eat lunch and type [Wink]

Kathy
(Getting the hang of it)
2002-09-16 08:17 PM
Re: Copying Shortcut

I read some links on LOADKEY and I came up with the following code. When I run it it says missing comma. Where. Will this work?

if ingroup("TX Mapcon Test")
Use O: /delete /PERSISTENT
USE O: "\\server\Apps\Apps"/PERSISTENT
LOADKEY (HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
\ICON, "ICON"="\\\\server\\netlogon\\short.bat")

endif
exit


Sealeopard
(KiX Master)
2002-09-16 08:22 PM
Re: Copying Shortcut

Kathy:

Please read the KiXtart Manual!

LOADKEY loads a registry key from a file. It does not write a registry value into the registry!

Thus, you are using a) incorrect LOADKEY syntax, b) incorrect command, c) did not check what both Lonkero and I posted per your request.


Kathy
(Getting the hang of it)
2002-09-16 08:23 PM
Re: Copying Shortcut

LONKERO: Thanks that did it!

LonkeroAdministrator
(KiX Master Guru)
2002-09-16 08:28 PM
Re: Copying Shortcut

heh, thanks to jens for clarification [Big Grin]

Sealeopard
(KiX Master)
2002-09-16 08:40 PM
Re: Copying Shortcut

I am tempted to say 'We applied a fix' but that would be inconsiderate though fitting considering Kathy's footer. [Wink]

Kathy: Glad we got it working now.

[ 16. September 2002, 20:41: Message edited by: sealeopard ]


Kathy
(Getting the hang of it)
2002-09-16 08:42 PM
Re: Copying Shortcut

I lied. I deleted the key and then rebooted and logged in. Did not put the change in the registry and did not load the shortcut.

Kathy
(Getting the hang of it)
2002-09-16 08:48 PM
Re: Copying Shortcut

Hey guys, when I run kix32 xxx from command line with the writevalue statement like you posted in the forum I get a 0 ZERO showing on the screen. What is that?

The code below is what I am running.
Kixtart 4.11 win98 users win2k servers
if ingroup("Test")
Use O: /delete /PERSISTENT
USE O: "\\server\Apps\Apps"/PERSISTENT
writevalue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce","icon","\\server\netlogon\start.bat","REG_SZ")


LonkeroAdministrator
(KiX Master Guru)
2002-09-16 09:01 PM
Re: Copying Shortcut

this is easy.
all functions have return value.

normally, 0 means that function was successfull.

from the functions description (manual) you see what it returns.

if you put $nul= or $rc= (like jens did) before the writevalue, it does not output it anymore.


Kathy
(Getting the hang of it)
2002-09-16 09:10 PM
Re: Copying Shortcut

Another "ignorance is showing question".
If a user deletes the icon from the desktop, next time he logs in does the registry setting put another on the desktop or does the "Runonce" know it has already run this and does not do anything?


LonkeroAdministrator
(KiX Master Guru)
2002-09-16 10:10 PM
Re: Copying Shortcut

hence the name runonce.
if you want it to run every time, put it in run key instead of runonce


Sealeopard
(KiX Master)
2002-09-16 10:13 PM
Re: Copying Shortcut

As 'RunOnce' implies, it'll run only once and then delete itself. In your case, where you try to force a desktop icon to be present on the users desktop all the time, you will need to check during every login script phase whether the link is there or not. If the link does not exist you rerun the RunOnce stuff. You can use EXIST to check for the presence of a file.

You want to do the check from within the login script since users can just remove the content of the Run key, thus preventing the update. Secondly, it is unnecessary to copy the link everytime.

[ 16. September 2002, 22:14: Message edited by: sealeopard ]