run a batch file from fwh

run a batch file from fwh

Postby Silvio.Falconi » Fri Oct 15, 2021 9: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 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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: run a batch file from fwh

Postby Marc Venken » Fri Oct 15, 2021 2: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1425
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: run a batch file from fwh

Postby Silvio.Falconi » Sat Oct 16, 2021 7: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 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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: run a batch file from fwh

Postby Silvio.Falconi » Sat Oct 16, 2021 11:23 am

sample :

Code: Select all  Expand view


#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
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: run a batch file from fwh

Postby Otto » 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: Select all  Expand view



      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
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: run a batch file from fwh

Postby Silvio.Falconi » Mon Oct 18, 2021 8: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: Select all  Expand view



      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 view
'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
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: run a batch file from fwh

Postby Otto » Mon Oct 18, 2021 8:10 am

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
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: run a batch file from fwh

Postby driessen » Mon Oct 18, 2021 9: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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: run a batch file from fwh

Postby Silvio.Falconi » Mon Oct 18, 2021 9: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 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: 7033
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 55 guests