Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Wednesday, June 18, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Run a command line Internal to SLX?
Carla Tillman
Posts: 290
 
Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 3:10 PM
fiogf49gjkf0d
Hi all;

I am trying to delete a file on an external machine from a specific user event inside of SLX. The files exist on an external Server that is not in the same domain as SLX. It is, however, running the SLXOLEDB provider - sending and receiving data to an outward facing web site.

One of the things I am looking at is the sysinternals tool of psexec. This tool works like a dream, when I have the ability to run it from command line. I feed it psexec, a small batch file, and a file variable.

Does anyone know how to run a command line from inside of SLX?

Example:
psexec \\myOtherServer -c c:\Myfolder\MyBatch.File c:\myVariableToNameThePathAndFile.file

eek! or is that Geek?

Carla
[Reply][Quote]
David Henry
Posts: 207
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 3:22 PM
fiogf49gjkf0d
Carla, try this:

psexec \\myOtherServer -u DOMAIN\username -p password -c c:\Myfolder\MyBatch.File c:\myVariableToNameThePathAndFile.file
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 3:31 PM
fiogf49gjkf0d
Hi David.

Thanks for the quick reply! I'm not having problems using the psexec. I just don't know how to call this run command from SLX. Suggestions?

i.e.
In SLX Active Form; from a button click

////////////////////////////////

Sub cmdMyAction_OnClick()

'gather information here to create my path and file

'run the command line .... with my params

End Sub




[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 3:49 PM
fiogf49gjkf0d
Hi Carla,

You can use the Shell object in a script to execute it by way of command.com. Something along these lines:

Dim shell 
Dim cmdline

cmdline = "psexec \\myOtherServer -c c:\Myfolder\MyBatch.File c:\myVariableToNameThePathAndFile.file"

Set shell = CreateObject("WScript.Shell")
shell.Run "command.com /k " & cmdline
Set shell = Nothing


This may or may not work, but worth a try. Otherwise, you could always just write out the entire command-line string to a text file, name it whatever.bat and then run that. Know what I mean?

-Ryan
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 3:51 PM
fiogf49gjkf0d
Thanks Ryan,

I'll give this a shot.

I think I know what you mean by the other. Create a fso object (create, write, close a text file) then execute it?

c
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 3:51 PM
fiogf49gjkf0d
BTW, you can also try enclosing the entire command line string in quotes - ie: Chr(34) & "my command line" & Chr(34). Also, I can't remember for sure if the param to command.com needs to be "k" or "c" to execute the command.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 3:53 PM
fiogf49gjkf0d
Quote:
Originally posted by Carla Tillman

Thanks Ryan,

I'll give this a shot.

I think I know what you mean by the other. Create a fso object (create, write, close a text file) then execute it?

c


Right.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 3:55 PM
fiogf49gjkf0d
One more thing, I think you can also use the environment var COMSPEC for this:

Dim shell

Set shell = CreateObject("WScript.Shell")
shell.Run = "%COMSPEC% " & cmdline
Set shell = Nothing


The COMSPEC var might use a newer construct than command.com, but I don't really remember for sure.
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 4:54 PM
fiogf49gjkf0d
Ryan,

Quick follow up:

%COMSPEC%
I tried this from an Active form and received the following error.

---------------------------
Script Error
---------------------------
...
...

Object doesn't support this property or method: 'shell.Run'
...

************************

However, it does appear the command.com version will work if I can get everything in the right place.

Carla
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 4:57 PM
fiogf49gjkf0d
What does the full code look like?
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 5:02 PM
fiogf49gjkf0d
I'm Fairly certain that moving my psexec and batch file to the SalesLogix folder or pathing it is all that is required at this point.


Sub DeleteLicKeyFile()


Dim shell
Dim cmdline
Dim PathAndFile


cmdline = "psexec \\MyServer -c c:\PStools\Delete.cmd " & "c:\testfolder\test.txt"
msgbox cmdline

Set shell = CreateObject("WScript.Shell")
Shell.Run "command.com /k " & cmdline
Set shell = Nothing

'This version returned the error

' Set shell = CreateObject("WScript.Shell")
' shell.Run = "%COMSPEC% " & cmdline
' Set shell = Nothing


End Sub
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 5:03 PM
fiogf49gjkf0d
p.s. full rights are inherited
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 5:27 PM
fiogf49gjkf0d
Change to this and you should be good to go (notice the "/C", I forgot that in my sample I posted earlier)

Sub DeleteLicKeyFile()
Dim shell
Dim cmdline

cmdline = "psexec \\MyServer -c c:\PStools\Delete.cmd " & "c:\testfolder\test.txt"

Set shell = CreateObject("WScript.Shell")
shell.Run = "%COMSPEC% /C " & cmdline
Set shell = Nothing

End Sub
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 07 6:03 PM
fiogf49gjkf0d
Still couldn't get that to go. I would have to poke around and see how my environment variables have been set.

However, I did finally get the syntax down on the other method. *WHEW* Rather than move my psexec and dangerous delete file to the SalesLogix folder, I wanted to keep it somewhat separate so I can apply at least a modicum of security.


Set shell = CreateObject("WScript.Shell")
Shell.Run "command.com /c" & "C:\PSTOOLS\" & cmdline
Set shell = Nothing


Thank you for all of your help Ryan. I was lost on this one!


Carla
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 May 07 3:10 PM
fiogf49gjkf0d
I know this is old but bear with me. Command.com is a Windows 98'ish thing. Windows NT (2000, XP, the only OS SalesLogix now supports) uses cmd.exe I believe. I think command.com is a simple pass-through to cmd.exe on those systems but you'll likely find a time soon where it may no longer be included.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 May 07 3:59 PM
fiogf49gjkf0d
That is true. I believe the %COMSPEC% env var maps to the most current command interpreter, which would be cmd.exe for any systems SLX runs on. The code could also use cmd.exe directly as well (which would be better than using command.com directly also).

Thanks for pointing that out.
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: Run a command line Internal to SLX?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 May 07 4:32 PM
fiogf49gjkf0d
Yeah - I talked to my network guy once I got the syntax right -trying to figure out why the %COMSPEC% wouldn't work in my environment. He wants me to switch it out to the cmd.exe for the same reasons.

Want to hear the ironic part? (Yes or No I'm going to tell you anyways ) It was one of those pieces of code you don't ever want to implement - a 'bandaid fix' for an integration that ... ---deleted comments ----. Well, the problem I was trying to resolve had already been fixed the 'right way' but never tested so no one told me!!! It would be funny if my dance card wasn't full...

The upshot of it is that Ryan and Google taught me something new.

c
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 6/18/2025 12:26:35 PM