Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Command line variable

Author  Topic 

DerbyNeal
Starting Member

3 Posts

Posted - 2014-10-23 : 11:07:18
Hi,

I am trying to produce a command line to be executed by/within at AT.exe scheduled task, using a variable which is populated within a SSIS 2008 script editor.


I have 2 variables:
User::GloVar is a read only variable
User::Arguments is a read/write variable

Dts.Variables("User::GloVar").Value = "ServerName1"

The script task:

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime


Public Sub Main()


Dts.Variables("User::Arguments").Value = "Cmd.exe /C \\" + Dts.Variables("User::GloVar").Value.ToString() + "\production\exe\Sched.exe /u:" + """\\ServerName2\Production\Production Files""" + " /XX output.fil"

Dts.Variables("User::Arguments").Value = Replace(Dts.Variables("User::Arguments").Value.ToString(), "Files\", "Files")

Dts.Variables("User::Arguments").Value = Replace(Dts.Variables("User::Arguments").Value.ToString(), "u:\", "u:")

End Sub



I need the output to be (hence the Replace functions):

Cmd.exe /C \\\\ServerName1\\production\\exe\\Sched.exe /u:"\\\\ServerName2\\Production\\Production Files" /XX output.fil



However, I'm getting the following, which has 2 additional backslash characters...

1 after "u:"
1 after "Files"
Cmd.exe /C \\\\ServerName1\\production\\exe\\Sched.exe /u:\"\\\\ServerName2\\Production\\Production Files\" /XX output.fil


Any ideas how I can remove them? Maybe I'm not using the Replace functions correctly, or can this can be done using another toolbox item.


Thanks in advance,

Neal Wright
   

- Advertisement -