Page 1 of 1 1
Topic Options
#205457 - 2012-07-11 08:53 PM Can you pass variable to Robocopy and run it
TimE Offline
Fresh Scripter

Registered: 2009-08-17
Posts: 5
Loc: Jacksonville, FL
Please be gently new to scripting. I have part of my script that I am trying to run. I need to know if you can pass a variable to robocopy.


$LocalPath = ReadValue("HKLM\software\Lotus\Notes" , "DataPath")
$ArchPath = $LocalPath + "Archive"
$Name=Split (@FULLNAME)
$name[0]=Left($name[0],1)
$name[1]=Left($name[1],5)
$Uname=Join($name,'') + ".nsf"
$Uname="arch_" + $Uname
$dest= "\\gideon\testarch "

$cmds='" ' + $archpath + '"' + ' ' + $dest + '"" + $uname + '"'

Shell 'robocopy' $cmds

When I run it, it flashes and does nothing. When I try to use %COMPSPEC% it tells me %COMSPEC% is not a valid command. If I run Shell 'robocopy "C:\Program Files\Lotus\Notes\Data\Archive" "\\gideon\testarch" arch_tedwar.nsf"' it runs perfectly. This is the same format I am trying to pass with the varible $cmds. Any help will be appreciated.

Top
#205458 - 2012-07-11 09:42 PM Re: Can you pass variable to Robocopy and run it [Re: TimE]
TimE Offline
Fresh Scripter

Registered: 2009-08-17
Posts: 5
Loc: Jacksonville, FL
One thing I noticed I have the $SO=SETOPTION("NoVarsInStrings", "ON"). So I changed my command to Shell "C:\Windows\System32\robocopy" + cmds. I get ERROR: unknown command C:\Windows\System32\robocopy
Top
#205459 - 2012-07-11 10:25 PM Re: Can you pass variable to Robocopy and run it [Re: TimE]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Hi Tim,

Try it like shown below.
It creates a command in the $line variable and then displays it for debugging so you can see if the line is correct or if it needs modifications. Once the line is correct remove the ; in front of the shell command and remove the ?$line and sleep 5 lines.

 Code:
$line="RoboCopy " + $archpath + " " + $dest + " " + $uname
?$line
sleep 5

;Shell $line
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#205460 - 2012-07-12 12:31 AM Re: Can you pass variable to Robocopy and run it [Re: Mart]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
You can give this a shot as well...

 Code:
$ArchPath = ReadValue("HKLM\software\Lotus\Notes" , "DataPath")+"Archive"
$Name=Split(@FULLNAME)
$Uname = "arch_"+Left($name[0],1)+Left($name[1],5)+".nsf"

$dest= "\\gideon\testarch"
$cmds='"'+$archpath+'" "'+$dest+'" "'+$uname+'"'

Shell 'robocopy '+$cmds

Top
#205461 - 2012-07-12 03:33 PM Re: Can you pass variable to Robocopy and run it [Re: ShaneEP]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I think Mart and Shane have you pointed in the right direction to solve your problem with forming the commandline with the needed quotes. I did write a few FAQs on the topic.

As for how you are trying to determine the user's mailfile by splitting @FullName, you are asking for trouble. What you should do is to locate and read their Notes.INI file and grab "MailFile" from it instead.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#205475 - 2012-07-18 08:25 PM Re: Can you pass variable to Robocopy and run it [Re: Les]
TimE Offline
Fresh Scripter

Registered: 2009-08-17
Posts: 5
Loc: Jacksonville, FL
Thanks for the inputs. I will try the suggestions and post a reply.
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 793 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.062 seconds in which 0.031 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org