Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
calling a WSF file Posted by delljohnb on 8 Oct 2003 at 9:30 AM
I'm wanting to call and execute a Windows Script from the body of my pascal code (I'm running 32 bit). Any suggestions? I tried calling it via a batch file, but the dos prompt environment won't let a WSF file run. The script has a known name (SNAPIN.WSF). The script will perform some tasks including running some other scrits and EXE files, then terminate and return functionality to by main Pascal program. I'm running FreePascal. Any quick and dirty suggestions? (I'm new to FreePascal) Your assistance is appreciated.

Delljohnb


Report
Re: calling a WSF file Posted by Manning on 8 Oct 2003 at 12:37 PM
: I'm wanting to call and execute a Windows Script from the body of my pascal code (I'm running 32 bit). Any suggestions? I tried calling it via a batch file, but the dos prompt environment won't let a WSF file run. The script has a known name (SNAPIN.WSF). The script will perform some tasks including running some other scrits and EXE files, then terminate and return functionality to by main Pascal program. I'm running FreePascal. Any quick and dirty suggestions? (I'm new to FreePascal) Your assistance is appreciated.

Just execute cscript.exe c:\path\to\snapin.wsf. I can't remember, but I believe FPC still has the Exec() function in the DOS unit, so you should be able to use that.
Report
close : do you have the syntax for exec()? Posted by delljohnb on 13 Oct 2003 at 9:34 AM
: : I'm wanting to call and execute a Windows Script from the body of my pascal code (I'm running 32 bit). Any suggestions? I tried calling it via a batch file, but the dos prompt environment won't let a WSF file run. The script has a known name (SNAPIN.WSF). The script will perform some tasks including running some other scrits and EXE files, then terminate and return functionality to by main Pascal program. I'm running FreePascal. Any quick and dirty suggestions? (I'm new to FreePascal) Your assistance is appreciated.
:
: Just execute cscript.exe c:\path\to\snapin.wsf. I can't remember, but I believe FPC still has the Exec() function in the DOS unit, so you should be able to use that.
:
Well....I think this may work. I added uses dos, and then exec() but is it giving me an "expected" compiling error. I'm assuming that I have the syntax wrong. I have looked in 5 different manuals, but I cannot find the correct syntax (whew...I'll be drinking heavily tonight...LOL). Do you have it?
Report
Re: close : do you have the syntax for exec()? Posted by Manning on 13 Oct 2003 at 10:19 AM
: : : I'm wanting to call and execute a Windows Script from the body of my pascal code (I'm running 32 bit). Any suggestions? I tried calling it via a batch file, but the dos prompt environment won't let a WSF file run. The script has a known name (SNAPIN.WSF). The script will perform some tasks including running some other scrits and EXE files, then terminate and return functionality to by main Pascal program. I'm running FreePascal. Any quick and dirty suggestions? (I'm new to FreePascal) Your assistance is appreciated.
: :
: : Just execute cscript.exe c:\path\to\snapin.wsf. I can't remember, but I believe FPC still has the Exec() function in the DOS unit, so you should be able to use that.
: :
: Well....I think this may work. I added uses dos, and then exec() but is it giving me an "expected" compiling error. I'm assuming that I have the syntax wrong. I have looked in 5 different manuals, but I cannot find the correct syntax (whew...I'll be drinking heavily tonight...LOL). Do you have it?


The first parameter is the program to run, and the second is the command-line parameters. In the old DOS days it always looked something like this:

Exec(GetEnv('COMSPEC'), '/C CSCRIPT C:\PATH\TO\SNAPIN.WSF');

But if you are using the Win32 version of FPC you might be able to get away with:

Exec('CSCRIPT', 'C:\PATH\TO\SNAPIN.WSF');

I haven't used Exec lately so I can't guarantee either will work. If they don't, you might need to use an API function like CreateProcess (which is fairly complicated)
Report
win32 syntax worked!!!! Posted by delljohnb on 13 Oct 2003 at 11:40 AM
: : : : I'm wanting to call and execute a Windows Script from the body of my pascal code (I'm running 32 bit). Any suggestions? I tried calling it via a batch file, but the dos prompt environment won't let a WSF file run. The script has a known name (SNAPIN.WSF). The script will perform some tasks including running some other scrits and EXE files, then terminate and return functionality to by main Pascal program. I'm running FreePascal. Any quick and dirty suggestions? (I'm new to FreePascal) Your assistance is appreciated.
: : :
: : : Just execute cscript.exe c:\path\to\snapin.wsf. I can't remember, but I believe FPC still has the Exec() function in the DOS unit, so you should be able to use that.
: : :
: : Well....I think this may work. I added uses dos, and then exec() but is it giving me an "expected" compiling error. I'm assuming that I have the syntax wrong. I have looked in 5 different manuals, but I cannot find the correct syntax (whew...I'll be drinking heavily tonight...LOL). Do you have it?
:
:
: The first parameter is the program to run, and the second is the command-line parameters. In the old DOS days it always looked something like this:
:
: Exec(GetEnv('COMSPEC'), '/C CSCRIPT C:\PATH\TO\SNAPIN.WSF');
:
: But if you are using the Win32 version of FPC you might be able to get away with:
:
: Exec('CSCRIPT', 'C:\PATH\TO\SNAPIN.WSF');
:
: I haven't used Exec lately so I can't guarantee either will work. If they don't, you might need to use an API function like CreateProcess (which is fairly complicated)
:


It worked like a charm!!!! I'm running it out of the root directory, so I left off the subdirectory switch. Many thanks!!! You are "da' man"...LOL

Delljohnb





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.