Author Topic: Batch file help  (Read 3231 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7531
Batch file help
« on: September 08, 2005, 04:18:52 PM »
So we have a login script.

First disconnect drive then reconnect.

How would I check to see if the drive is connected......and then disconnect. If it does not exist....ignore it?

Something like this:

If Net Use F: = true
Net Use F: /Del /YES
else goto
If Net Use J: = true
Net Use J: /Del /YES

thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

deegeecees

  • Guest
Re: Batch file help
« Reply #1 on: September 08, 2005, 04:26:13 PM »
Here is what I was handed by Hudster:

Quote
@echo off

net use p: /delete
net use p: \\lisledc1\projects

net use q: /delete
net use q: \\lisledc2\projectscomed

net use s: /delete
net use s: \\lisledc2\programs

net time \\lisledc2 /set /yes

If "%OS%" == "Windows_2000" goto skip
:skip

It doesn't take into consideration current connection status. Its more of a brute force method. Delete drive, then reconnect using the proper mapping.
« Last Edit: September 08, 2005, 04:33:05 PM by deegeecees »

Bob Wahr

  • Guest
Re: Batch file help
« Reply #2 on: September 08, 2005, 04:56:33 PM »
you can either pick a file that will always be on the drive or make a bogus file like "connected.txt", then do

Code: [Select]
If not exist F:\connected.txt
goto skipF
Net Use F: /Del /YES

:skipf
If not exist J:\connected.txt
goto skipJ
Net Use J: /Del /YES

:skipJ
*anything else you want to do before leaving*
echo Da shizzle is finizzled.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Batch file help
« Reply #3 on: September 08, 2005, 05:08:45 PM »
Thanks Bob, I'll give it a try.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Bob Wahr

  • Guest
Re: Batch file help
« Reply #4 on: September 08, 2005, 05:15:58 PM »
It might need some tweaking, been awhile since I've been up to BAT, but it should get you started.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Batch file help
« Reply #5 on: September 26, 2005, 01:12:37 PM »
Hey Bob (or anyone else),

Do you know how to compare the date modified attribute or filesize for two files.

Something like:  if c:\file1size equal c:\file2size goto skip

You're solution worked for my other question....you don't have to have a file to look for though....it works just checking for a folder location.

Code: [Select]
if not exist "%programfiles%\AutoCAD Tools\" goto SKIPAROONIE
"S:\-AutoCAD Routines-\Updater\Update Lisp Routines.bat"
:SKIPAROONIE

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Bob Wahr

  • Guest
Re: Batch file help
« Reply #6 on: September 26, 2005, 01:45:42 PM »
maybe with COMP

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Batch file help
« Reply #7 on: September 26, 2005, 03:04:31 PM »
FYI..

It was easier to use a 3rd party app (from what I read)...

http://www.programmersheaven.com/zone16/cat913/19947.htm

Syntax: gscmp [FILE1] [FILE2]

Return Values
-------------
0 - The files are identical.
1 - The files differ in size.
2 - The files differ in content.

The batch file looks like this:

gscmp "C:\file1" "X:\file2"
if %errorlevel% == 0 goto SKIPINSTALL
F:\somepath\myprog.exe
:SKIPINSTALL

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Batch file help
« Reply #8 on: September 26, 2005, 07:17:20 PM »
;;to detect if drive exist.
(vl-file-size "k:/") ;;return nil if not
;;or
(vl-file-directory-p "v:/")


;;to detect the size of the file (if exist)
(vl-file-size "c:/test.txt");;return nil if not exist



;;to detect the file Date
(vl-file-systime "c:/program files/AutoCAD 2004/sample/visuallisp/yinyang.lsp")

so I think with theses command you can do everything you need...

But if you need this to do a Batch file scripting...
take a look Here...


« Last Edit: September 26, 2005, 07:29:51 PM by Andrea »
Keep smile...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Batch file help
« Reply #9 on: September 26, 2005, 07:24:54 PM »
Yep, Lisp will work Andrea . but he is after a system Script < .BAT file >
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Batch file help
« Reply #10 on: September 26, 2005, 07:31:14 PM »
Oops..... :|
Keep smile...