Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login script - disable the close window/command prompt window

Status
Not open for further replies.

toby77jo

Programmer
May 4, 2006
35
0
0
BE
Hi,

I am using a login.bat file to map network drives, sync files with some vbs files etc.

My question is, can I make it impossible for the users to close the command prompt window that is opened from the login.bat file? My problem is that some users close the window before all scripts have finished to run.
 
Why don't you get rid of your batch file and use VBS for your login script?

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
how would i convert this to vbs?

@echo off

net use z: /delete
net use y: /delete
net use x: /delete
net use v: /delete
net use w: /delete
net use s: /delete
net use p: /delete

net use z: \\ade-storage\DATA\z
net use y: \\ade-storage\INITIALES\y
net use x: \\ade-storage\Installs
net use v: \\ade-web\websitedata /user:ade\%USERNAME% /persistent:no
net use w: \\ade-web\Website /user:ade\%USERNAME% /persistent:no
net use s: \\ade-domain\Mail\%USERNAME% /user:ade\%USERNAME% /persistent:no
net use P: \\ade-storage\Data\z\Permanents\%USERNAME% /persistent:no
net time \\ADE-STORAGE /SET /Yes

\\Ade-storage\Installs\scripts\mailbackup.vbs

XCOPY "%USERPROFILE%\My Documents\Working documents\*" "\\Ade-storage\DATA\z\Permanents\%USERNAME%" /D /s /i /c /r /y

REM if exist "c:\ADE\CV_DB.mdb" copy "\\Ade-server\INITIALES\ADE-DB\CV_DB.mdb" "c:\ADE\CV_DB.mdb"

SET COPYCMD=/Y
XCOPY "Z:\ADEDOT\Templates ADE\*" "%USERPROFILE%\Application Data\Microsoft\Templates\Templates ADE" /D /s /i /c /r /y
 
Check out this superb FAQ by Markdmac

faq329-5798

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
XCOPY "%USERPROFILE%\My Documents\Working documents\*" "\\Ade-storage\DATA\z\Permanents\%USERNAME%" /D /s /i /c /r /y

How can i achieve this in a vbs, with xcopy I am using flags to only copy files which have a different timestamp in the file?

I do not want to copy a users "My documents" unless files have changed since last logon also I only want to copy those files that changed.

What is the code for that in vbs? objFSO.CopyFile...??
 
Why not simply use synchronised folders ?
 
how do i use syncronized folders in a vbs for all users in our domain?
 
You turn on Folder Syncronization in Group Policy.

Are you still running Windows NT? Your post has the following:

Code:
net time \\ADE-STORAGE /SET /Yes

That command should not be used in a Windows 2000 or 2003 environment.

I too would recommend you switch to VBScript and use my FAQ as a guide as TheLad suggested.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
I have come to the conclusion that I do not want to use syncronised folder. Is there a way in vbs to achieve this

if exist "%USERPROFILE%\My Documents\Working documents" XCOPY "%USERPROFILE%\My Documents\Working documents\*" "\\Ade-storage\DATA\z\Permanents\%USERNAME%" /D /s /i /c /r /y
if exist "%USERPROFILE%\My Documents\Workingdocuments" XCOPY "%USERPROFILE%\My Documents\Workingdocuments\*" "\\Ade-storage\DATA\z\Permanents\%USERNAME%" /D /s /i /c /r /y
 
in my login.vbs can I execute the bat file that contains the code (I would put the execute at the end in the vbs) ?

if exist "%USERPROFILE%\My Documents\Working documents" XCOPY "%USERPROFILE%\My Documents\Working documents\*" "\\Ade-storage\DATA\z\Permanents\%USERNAME%" /D /s /i /c /r /y
if exist "%USERPROFILE%\My Documents\Workingdocuments" XCOPY "%USERPROFILE%\My Documents\Workingdocuments\*" "\\Ade-storage\DATA\z\Permanents\%USERNAME%" /D /s /i /c /r /y
 
Yes you can use something like:

Set objFSO = CreateObject("Scripting.FileSystemobject")

If objFSO.FileExists(blah) Then
objFSO.CopyFile blah, blah2
End If

You can use the WSH Special folders to find the My Docs location.

Abandon all thoughts of bat files. This can and should all be a pure vbscript solution.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
I just did a test and nothing is being copied

Set objFSO = CreateObject("Scripting.FileSystemobject")

If objFSO.FileExists("c:\test\*") Then
objFSO.CopyFile "c:\test\*", "d:\test"

End If

What if there are subfolders?

What is the flag for this to only copy modified files since last copy session?

You say I can use WSH Special folders to find My Documents, how would I use that in your example?

something like this or not?

set WshShell = WScript.CreateObject("WScript.Shell")
strDocs = WshShell.SpecialFolders("My Documents")
Set objFSO = CreateObject("Scripting.FileSystemobject")

If objFSO.FileExists("strDocs") Then
objFSO.CopyFile "strDocs", "d:\test"
End If


 
You cannot test fileexists() with a wild card. The documentation is your only friend.
 
Bart.gif


I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
ok I am trying my best here, I admit, I am a newbie!!

What may be wrong with this code..

set WshShell = WScript.CreateObject("WScript.Shell")
strDocs = WshShell.SpecialFolders("MyDocuments")
WScript.Echo(strDocs)

Set objFSO = CreateObject("Scripting.FileSystemobject")

If objFSO.FolderExists(strDocs & "\working documents") Then
objFSO.CopyFolder strDocs & \working documents, "\\ade-storage\permanents\%username%\docs", True
End If
 
Trailing \ missing - \\ade-storage\permanents\%username%\docs\

This will copy the folder "working documents" into the "docs" folder.
 
thanks it is working now. I have tried to find on google how to syncronize the time on each workstation, i can't find it anywhere, anyone knows how to sync the time with vbs?
 
You don't. Time syncronization is the job of your domain controllers. If that is not happening you need to look into that from the Windows side. Forcing syncronization only masks a larger problem.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
I would first check into what markdmac has suggested, but if you run into issues, like I do here at my work, you can handle a time sych on a specific workstation by using "NET TIME".
I found the best way to run this, remotely, is to use the pstools from The tool "PSEXEC" will allow you to connect to that individuals CMD window so that you can run the NET TIME.
To check the remote machines time: (from inside a cmd window)
NET TIME \\<machine>

To connect to remote machines cmd to adjust time:
psexec \\<machine> cmd

NET TIME \\<server> /set /y
(<server> is the machine you want to synch that machines time to)
 
I am now using the wonderful script from markdmac , I have run into one problem though, I am enumerating all the network printers, deletes them, and remount all the network printer, when doing that automatically each user loses his personal settings for the printers they are using, how may I put in the script a check to only mount new printers that did not exist before? Should I stop uninstallations of the network printers in the login script and put some code to only install them on first run of the script? how can I achieve this ??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top