run a batch file from fwh

Post Reply
User avatar
Silvio.Falconi
Posts: 7133
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

run a batch file from fwh

Post by Silvio.Falconi »

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 November 2023 - January 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
User avatar
Marc Venken
Posts: 1485
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: run a batch file from fwh

Post by Marc Venken »

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
User avatar
Silvio.Falconi
Posts: 7133
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: run a batch file from fwh

Post by Silvio.Falconi »

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 November 2023 - January 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
User avatar
Silvio.Falconi
Posts: 7133
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: run a batch file from fwh

Post by Silvio.Falconi »

sample :

Code: Select all | Expand



#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 November 2023 - January 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
User avatar
Otto
Posts: 6403
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 24 times
Been thanked: 2 times
Contact:

Re: run a batch file from fwh

Post by Otto »

Hello Silvio,

Do you run your EXE as admin?

I use the same code as you with no problems.

Best regards,
Otto

Code: Select all | Expand




      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


 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Silvio.Falconi
Posts: 7133
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: run a batch file from fwh

Post by Silvio.Falconi »

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: Select all | Expand




      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: Select all | Expand

'WMIC USERACCOUNT WHERE
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Otto
Posts: 6403
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 24 times
Been thanked: 2 times
Contact:

Re: run a batch file from fwh

Post by Otto »

Silvio, WINDOWS is a very save OS.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
driessen
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: run a batch file from fwh

Post by driessen »

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. 24.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
Silvio.Falconi
Posts: 7133
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: run a batch file from fwh

Post by Silvio.Falconi »

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 November 2023 - January 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
Post Reply