Page 1 of 1 1
Topic Options
#144798 - 2005-08-04 04:51 PM Create directory if not exists
seven Offline
Fresh Scripter

Registered: 2005-05-30
Posts: 6
Loc: Netherlands
Hi I need to copy some data to a folder.
But before copying I would like to check id fthe directory exists if not create it.
i finally this folder needs to be hidden.

Here is my script....for some reason it is not working..

$wksta = @WKSTA
$robocmd= %logonserver%\netlogon\tools\robocopy.exe
$roboparms= "/MIR \\bre1mb601\startmenu$\basis *.* h:\TS-MENU\ /r:0 /w:1 > nul"

;Opbouwen startmenu voor terminal server gebruikers


if $wksta = '0435xp' OR $wksta = 'bre1mb601' OR $wksta = 'bre1mb602'
IF exists (@homedir + "\ts-menu\")

else
shell '%comspec% /c md "h:\ts-menu"/s /q >nul 2>nul'

SETFILEATTR (h:\ts-menu, 2)
endif

Shell '%COMSPEC% /c '+$robocmd+' '+$roboParms

? 'copy succesfull....' ? ?
endif

Top
#144799 - 2005-08-04 04:54 PM Re: Create directory if not exists
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
do you have novarsinstrings turned to "ON"?

if not, then this line.
Code:

$roboparms= "/MIR \\bre1mb601\startmenu$\basis *.* h:\TS-MENU\ /r:0 /w:1 > nul"



could be causing you some problems and you will need to double up on the "$"

Top
#144800 - 2005-08-04 05:03 PM Re: Create directory if not exists
seven Offline
Fresh Scripter

Registered: 2005-05-30
Posts: 6
Loc: Netherlands
Copying is working fine.
If I create the directory manually and comment out the directory check,then it works.

I'm not using the VarsinString option...
So the problem is not in cpoy piece but in the dir check

Thanks for the reply

seven


Edited by seven (2005-08-04 05:04 PM)

Top
#144801 - 2005-08-04 05:28 PM Re: Create directory if not exists
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well...
IF exists (@homedir + "\ts-menu\")

what is @homedir?
_________________________
!

download KiXnet

Top
#144802 - 2005-08-04 05:29 PM Re: Create directory if not exists
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
and my bet is, it is "h:\" and thus making the check translate to:
if exist("h:\\ts-menu\")
_________________________
!

download KiXnet

Top
#144803 - 2005-08-04 06:12 PM Re: Create directory if not exists
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Also, sice he failed to wrap it in quotes, I think KiX might try to do math on:
SETFILEATTR (h:\ts-menu, 2)

Missing quotes here too:
$robocmd= %logonserver%\netlogon\tools\robocopy.exe
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

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.064 seconds in which 0.033 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