FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour run a batch file from fwh
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
run a batch file from fwh
Posted: Fri Oct 15, 2021 09:13 AM
I need to start a batch file that has only one command line from an exe fwh
in the command line enclosed in the bat file it wants three parameters %1 %2 %3
instead of these three parameters the information contained within a dbf must be linked

example
First, Last, Address

any help pls
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: run a batch file from fwh
Posted: Fri Oct 15, 2021 02:12 PM

I would generate/update the bat file itself with the dbf data, just before running it from FWH.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: run a batch file from fwh
Posted: Sat Oct 16, 2021 07:06 AM

perhaps I resolved
I created a txtfile from fwh
and then save as "xxx.bat"
then I make run this bat
But there is a problem because the command I insert on it need level administrator because there is a command NET USER

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: run a batch file from fwh
Posted: Sat Oct 16, 2021 11:23 AM
sample :

Code (fw): Select all Collapse
#include "fivewin.ch"

Function test()
local cText := ""
local cUser:="Pon2021"
local cPassword:="Pon"
  
  
    cText += " NET USER " +cUser +" "+;
                           cPassword +" /add " +;
                        " /comment='Pon 2021'" +;
                        " /expires:never " +;
                        " /passwordchg:No" +;
                        " /logonpasswordchg:No"


    memowrit("test.bat", cText )
    waitrun( "test.bat", 0 )
return nil




this created the file .bat
then it is no executed why ?


if you run cmd from administrator and then write
NET USER fwh fwh /add
it execute and create a user called fwh with password fwh
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: run a batch file from fwh
Posted: Sat Oct 16, 2021 11:44 AM
Hello Silvio,

Do you run your EXE as admin?

I use the same code as you with no problems.

Best regards,
Otto

Code (fw): Select all Collapse
      if  lIsDir( cVerzeichnis ) = .f.

         lMKDir( cVerzeichnis )
         cText :=  'net user ' + cUser + ' ' +  cPW + ' /add /comment:"Basic WINHOTEL Remotedesktop user account." /fullname:"' + cfullname +'" /logonpasswordchg:no' + CRLF
         cText := cText + 'net localgroup "Remotedesktopbenutzer" '+ cUser +' /add' + CRLF
         cText := cText + 'net localgroup "Benutzer" ' + cUser + ' /delete' + CRLF
         cText := cText + 'WMIC USERACCOUNT WHERE "Name=' + "'"  + cUser  + "'" + '" SET PasswordExpires=FALSE' + CRLF
         memowrit( ".\psfiles\ps_8.bat", cText )
         waitrun( ".\psfiles\ps_8.bat" )
endif
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: run a batch file from fwh
Posted: Mon Oct 18, 2021 08:02 AM
Otto wrote:Hello Silvio,

Do you run your EXE as admin?

I use the same code as you with no problems.

Best regards,
Otto

Code (fw): Select all Collapse
      if  lIsDir( cVerzeichnis ) = .f.

         lMKDir( cVerzeichnis )
         cText :=  'net user ' + cUser + ' ' +  cPW + ' /add /comment:"Basic WINHOTEL Remotedesktop user account." /fullname:"' + cfullname +'" /logonpasswordchg:no' + CRLF
         cText := cText + 'net localgroup "Remotedesktopbenutzer" '+ cUser +' /add' + CRLF
         cText := cText + 'net localgroup "Benutzer" ' + cUser + ' /delete' + CRLF
         cText := cText + 'WMIC USERACCOUNT WHERE "Name=' + "'"  + cUser  + "'" + '" SET PasswordExpires=FALSE' + CRLF
         memowrit( ".\psfiles\ps_8.bat", cText )
         waitrun( ".\psfiles\ps_8.bat" )
endif


thanks Otto
I thought that I could directly load test.bat an exe program and load it in administrator mode,
now I have to remember to load the exe in administrator mode

a question
what do you do with the command
Code (fw): Select all Collapse
'WMIC USERACCOUNT WHERE
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: run a batch file from fwh
Posted: Mon Oct 18, 2021 08:10 AM

Silvio, WINDOWS is a very save OS.
Best regards,
Otto

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: run a batch file from fwh
Posted: Mon Oct 18, 2021 09:33 AM

Silvio,

Why don't you make a LNK-file (like shortcut) in which you can define to run it as an administrator.
In your application you use the

WaitRun("XXXX.LNK,0)

Doesn't that work?

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: run a batch file from fwh
Posted: Mon Oct 18, 2021 09:45 AM
driessen wrote:Silvio,

Why don't you make a LNK-file (like shortcut) in which you can define to run it as an administrator.
In your application you use the

WaitRun("XXXX.LNK,0)

Doesn't that work?


I have at my school 3 labs with 22 computer each I wish to find a faster way to create user accounts for students
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion