Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

calling a WSF file

delljohnbdelljohnb Posts: 81Member
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


Comments

  • ManningManning Posts: 1,621Member
    : 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 osnapin.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.
  • delljohnbdelljohnb Posts: 81Member
    : : 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 osnapin.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?
  • ManningManning Posts: 1,621Member
    : : : 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 osnapin.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:PATHTOSNAPIN.WSF');

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

    Exec('CSCRIPT', 'C:PATHTOSNAPIN.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)
  • delljohnbdelljohnb Posts: 81Member
    : : : : 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 osnapin.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:PATHTOSNAPIN.WSF');
    :
    : But if you are using the Win32 version of FPC you might be able to get away with:
    :
    : Exec('CSCRIPT', 'C:PATHTOSNAPIN.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


Sign In or Register to comment.