Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Logon Script

Posted on 2004-10-29
16
Medium Priority
?
369 Views
Last Modified: 2010-04-10
Hi There,
please excuse my ignorance but how do you write a logon script that will do the following:


1/ Delete the folder - c:\Program Files\RealDownload
2/ Delete the folder - c:\Program Files\RealRealJukebox
3/ Delete the folder - c:\Program Files\RealPlayer
4/ Do this without notifying the user - i.e no dialogue boxes appear asking if it's alright to delete the files
5/ Sorry it should check if the folders in 1-3 exist first then delete them if they do, else exit script if they don't

Win NT4 Servers
Win98 Workstations

Many Thanks in advance

Michael
0
Comment
Question by:daleoran
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
  • +1
16 Comments
 

Accepted Solution

by:
jjernst earned 800 total points
ID: 12443114
Hi Michael,

Two parts:

First, you need to write a batch file containing the commands. Jus in case, here's a short 'how to' on writing batch files:

- Create a new text document.
- Edit the document and add the commands which need to be executed by the script. In your case the commands should be:

IF  EXIST "c:\program files\realdownload" RD "c:\program files\realdownload" /y
IF  EXIST "c:\program files\realrealjukebox" RD "c:\program files\realrealjukebox" /y
IF  EXIST "c:\program files\realplayer" RD "c:\program files\realplayer" /y

- Save and close the file
- Change it's file extention from .txt to .bat. You need to have the display options in your explorer configured to display all file extentions, even the known ones.
- Copy the script to the following folder on the NT4 Server: c:\winnt\system32\repl\import\scripts
Once the script is there, it should replicate to the other servers.

Second, in the user administration window on the server, you need to add the script to each user on whose PC you want it to run at login.
Open the user's properties window and, i think on the second tab, you should find a text field labled 'logon script'. You need to add the path to the logon script there. Once done, confirm with ok. As soon as all the replications have been completed successfuly between the servers, the settings should take effect.

One thing I'd like to point out: in windows 98, the login script runs visibly, meaning a command prompt will open and execute the commands and the user will see that command prompt. The user can also close it by clicking on the 'x' button, thus interrupting the batch file... It is a little problem, to which i don't know if there are any solutions under win 98.
All I know is that from win 2k up, you can use group policy to hide the login script and even tell it to not load the user's desktop and settings before the script has finished.

Hope this helped you. Tell me if it worked.

Regards, Christian
0
 
LVL 3

Assisted Solution

by:cmsJustin
cmsJustin earned 400 total points
ID: 12443465
It might be a good idea to add the following lines to the beginning of the script:

@echo off
cls

This will make it so that the user cannot see the process at all

-Justin
0
 

Expert Comment

by:jjernst
ID: 12443527
Thanks Justin! Good idea.

So that makes:

@echo off
cls

IF  EXIST "c:\program files\realdownload" RD "c:\program files\realdownload" /y
IF  EXIST "c:\program files\realrealjukebox" RD "c:\program files\realrealjukebox" /y
IF  EXIST "c:\program files\realplayer" RD "c:\program files\realplayer" /y

Regards
0
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 
LVL 10

Author Comment

by:daleoran
ID: 12444026
Hi All,
Many thanks for the replies. So what am i I doing wrong? :(
jjernst - I've done exactly as you have described in you post (ignoring the 'echo off' for now - will add later)
But nothing seems to be happening. When I log in as the test user I see the message 'Please wait to your login script is executed' (or words to that effect). But when I check the C: drive the folders are still there.
If I copy the .bat file onto the C: drive and execute it there the same thing happens - the folders remain.

Any ideas?

Michael
0
 
LVL 18

Expert Comment

by:Sham Haque
ID: 12444249
are you sure your users log in with sufficient priveleges to be able to remove these folders?

if so, then i wonder what the prob is apart from the bat jjernst suggested.
i'm not sure why you're bothering to do the check if they exist - it ignores if they're not there anyway.

try this instead:

del "c:\program files\realdownload\*.*" /q /s
del "c:\program files\realrealjukebox\*.*" /q /s
del "c:\program files\realplayer\*.*" /q /s
RD "c:\program files\realdownload" /q /s
RD "c:\program files\realrealjukebox" /q /s
RD "c:\program files\realplayer" /q /s

the /q switch operates in "quiet" mode, meaning in the background without your users seeing anything.

instead of adding it to the login script, try adding it to the startup folder for the user - maybe something like "c:\windows\profiles\start menu\startup"
this then runs AFTER logon but before they can use the PC.

suck it and see.....

Shammy
0
 
LVL 10

Author Comment

by:daleoran
ID: 12444475
Hi Shammy,
Nearly there - I think
The script runs if I put it in the startup but I get an 'Invalid switch' error message for both the /q & /s
If I remove these switches I'm asked if I want to delete the files - I want to avoid this.

Any ideas?

Michael
0
 
LVL 18

Expert Comment

by:Sham Haque
ID: 12444643
your workstations running Win98?
it's been a while since i used that baby - what options do you get when you type "del /?" in a command window?
0
 
LVL 18

Assisted Solution

by:Sham Haque
Sham Haque earned 800 total points
ID: 12444852
ok - remove the /q /s switches - weren't introduced for DOS 7.1!

with no switch you should get no confirmation (only available switch for DEL is /p - which is force confirmation)

you could also try adding a >nul redirector - output does not go to screen then
del "c:\program files\realdownload\*.*"

another alternative is to use DELTREE with a /y switch - this does away with the need to use DEL then RD.
eg

deltree "c:\program files\realdownload" /y
deltree "c:\program files\realrealjukebox" /y
deltree "c:\program files\realplayer" /y

it's been a while since i was down that road.....

0
 
LVL 18

Expert Comment

by:Sham Haque
ID: 12444874
the middle bit should've read:

del "c:\program files\realdownload\*.*" >nul

[mods: could you not look at answerers being able to edit posts pls?]
0
 
LVL 10

Author Comment

by:daleoran
ID: 12446049
Hi gbshahaq
many thanks for the replies. Unfortunately I'm not back to work until Monday, so if you can hang fire 'til then I'll let you know how it goes.

Michael

0
 
LVL 3

Expert Comment

by:cmsJustin
ID: 12446517
Maybe try to replace RD with RMDIR. I think the sytax may have been different on NT4.
Or try the other suggestions above.
I dont think DEL will delete directories, only files.

-Justin
0
 
LVL 10

Author Comment

by:daleoran
ID: 12463753
Hi All,
sorry, but all the above suggestions still leave me being asked to confirm the deletion of the files (which I don't want). Whats the command to see the version of dos that's running?

Michael

0
 
LVL 10

Author Comment

by:daleoran
ID: 12464206
have found this switch - if I create a txt file containing just the letter y and a carriage return and then use the switch <yes.txt as shown below the files are deleted with no confirmation :)

rem
rem delete RealPlayer
rem
del "c:\program files\realplayer\msg\*.*" <yes.txt
del "c:\program files\realplayer\setup\*.*"  <yes.txt
del "c:\program files\realplayer\*.*"  <yes.txt

Once this is done how do I close the command window - I thought putting 'exit' (without the quotes) at the end of the .bat file would do it but it doesn't

Michael

0
 
LVL 18

Expert Comment

by:Sham Haque
ID: 12464280
WIN NT, 95, 98, ME:

use deltree with a /y parameter - to suppress prompts
eg. deltree "c:\program files\realdownload" /y

Win 2000, XP:

use RD / RMDIR with a /s /q parameter - to suppress prompts
eg. RD "c:\program files\realplayer" /q /s

if you have the redirector >nul on, it will suppress showing the files removed.
as long as you have this set as is, and save as a bat file, the DOS window definitely should close after deleting

Shammy
0
 
LVL 10

Author Comment

by:daleoran
ID: 12503651
Sorry for the delay - I've been side-tracked and will get back asap.
Thanks for you patience

Michael
0
 
LVL 10

Author Comment

by:daleoran
ID: 12663050
Again I apologise for not getting back to you on this one. I have been side tracked but will get back to this asap - the joys of being a one man IT dept :)

Thanks for your patience

Michael

0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Tech spooks aren't just for those who are tech savvy, it also happens to those of us running a business. Check out the top tech spooks for business owners.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question