Sign in to follow this  
Followers 0
Iain

Help with bat to gui

5 posts in this topic

#1 ·  Posted (edited)

Afternoon All,

I was recommended Autoit to help GUI my batch file and make it more user friendly. When Openeing my batch file with SciTE it finds several syntax issues eg - CD\

Does it have the capability of correcting these or can you suggest what the best way to convert to au3 would be so I can create my .exe?

I have done a search on the site, but might be missing the obvious?

Any help would be appreciated.

All the best,

Iain.

Edited by Iain

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This is my script

cd\
cls
@echo off

:RESTART

%windir%\system32\xcopy.exe "\\app-server\USMT\Engine\dsmod.exe" "%systemroot%\system32" /y /q
%windir%\system32\xcopy.exe "\\app-server\USMT\Engine\dsquery.exe" "%systemroot%\system32" /y /q

ECHO DSQUERY AND DSMOD COPIED TO SYSTEM32

cd\


@echo off
cls
goto menu

:menu
echo.
echo Where do you want to back the users data to?
echo.
echo Choice
echo.
echo 1 Network Location
echo 2 USB Drive
echo 3 Local Disk C:\
echo 4 Quit
echo.


:choice
set /P C=[Press 1 2 3 or 4 to Quit ]
if "%c%"=="1" goto network
if "%c%"=="2" goto usb
if "%c%"=="3" goto local
if "%c%"=="4" goto end


REM ####START OF NETWORK SECTION####
:network

cls

echo Specify the username for the data storage folder e.g David.Charlton
set /p Folder_Name=

cls

SET Choice=
echo ............................................................................
echo ............................................................................
SET /P Choice=THE FOLDER "%Folder_Name%" WILL BE CREATED. SHALL WE PROCEED [Y,N]?
IF /I '%Choice%'=='Y' GOTO START
IF /I '%Choice%'=='N' GOTO RESTART


:START

md \\n03xp01\usmt\%Folder_Name%

cd\

dsquery user -name %Folder_Name% | dsmod group "CN=Desktop Data Transfer,OU=Groups,OU=Migrated objects,DC=Sageukie,DC=adinternal,DC=com" -addmbr

pause:

@echo off

Rem Begin USMT

Rem Copy USMT files locally

cd\

MD USMT

%windir%\system32\xcopy.exe "\\app-server\usmt\usmt\*.*" "c:\USMT" /y /q


Rem begin scanstate (also creates directory of username)

echo ..................................................................................
echo TRANSFERRING FILES AND SETTINGS TO NETWORK LOCATION \\n03xp01\usmt\%Folder_Name%
echo ..................................................................................

c:\usmt\scanstate.exe \\n03xp01\usmt\%Folder_Name% /i:miguser.xml /i:migapp.xml /i:migsys.xml /ue:*\* /ui:sageukie\%Folder_Name% /localonly /o /c



pause:

goto end

:usb
rem ####START OF USB COPY SECTION####
rem ####find removable drives####

cls
@echo off

setlocal enabledelayedexpansion
set UsbNum=0
for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
  for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable"') do (
    set /a UsbNum+=1
    set DriveU!UsbNum!=%%h
  )
)
echo You have !UsbNum! removable drives, shown below:
for /l %%a in (1,1,!UsbNum!) do (
  echo.!DriveU%%a!
)

if "!usbnum!"=="1" goto startusb
if NOT "!usbnum!"=="1" goto multiusb

endlocal

:multiusb
rem #### IF YOU HAVE MORE THAN ONE REMOVEABLE DRIVE####
cls
echo.
echo ********  WARNING WARNING WARNING!!!!!!  ********
echo.
echo ********  I HAVE DETECTED EITHER MORE THAN ONE REMOVEABLE USB DRIVE OR NO REMOVABLE DRIVE IS PRESENT!  ********
echo.
echo ********  PLEASE CHECK YOUR USB CONNECTION AND MAKE SURE ONLY ONE DRIVE IS INSERTED  ********
echo.

pause
rem :end
exit

:startusb
rem ####JUST ONE DRIVE, LETS CRACK ON...####
cls

echo Specify the username for the data storage folder e.g David.Charlton
set /p Folder_Name=

cls

SET Choice=
echo ............................................................................
echo ............................................................................
SET /P Choice=THE FOLDER "%Folder_Name%" WILL BE CREATED. SHALL WE PROCEED [Y,N]?
IF /I '%Choice%'=='Y' GOTO START
IF /I '%Choice%'=='N' GOTO RESTART


:START

setlocal enabledelayedexpansion
set UsbNum=0
for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
  for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable"') do (
    set /a UsbNum+=1
    set DriveU!UsbNum!=%%h
  )
)
echo You have !UsbNum! removable drives, shown below:
for /l %%a in (1,1,!UsbNum!) do (
  echo.!DriveU%%a!

md "!DriveU%%a!"\usmt\%Folder_Name%

@echo off

Rem Begin USMT

Rem Copy USMT files locally

cd\

MD USMT

%windir%\system32\xcopy.exe "\\app-server\usmt\usmt\*.*" "c:\USMT" /y /q


Rem begin scanstate (also creates directory of username)

echo ..................................................................................
echo TRANSFERRING FILES AND SETTINGS TO USB DRIVE "!DriveU%%a!"\usmt\%Folder_Name%
echo ..................................................................................

c:\usmt\scanstate.exe "!DriveU%%a!"\usmt\%Folder_Name% /i:miguser.xml /i:migapp.xml /i:migsys.xml /ue:*\* /ui:sageukie\%Folder_Name% /localonly /o /c


)

endlocal

pause

:end
exit

rem ###### start of local copy section ######

:local

cls

echo Specify the username for the data storage folder e.g David.Charlton
set /p Folder_Name=

cls

SET Choice=
echo ............................................................................
echo ............................................................................
SET /P Choice=THE FOLDER "%Folder_Name%" WILL BE CREATED. SHALL WE PROCEED [Y,N]?
IF /I '%Choice%'=='Y' GOTO START
IF /I '%Choice%'=='N' GOTO RESTART


:START

md c:\usmtmig\%Folder_Name%

@echo off

Rem Begin USMT

Rem Copy USMT files locally

cd\

MD USMT

%windir%\system32\xcopy.exe "\\app-server\usmt\usmt\*.*" "c:\USMT" /y /q


Rem begin scanstate (also creates directory of username)

echo .......................................................................
echo TRANSFERRING FILES AND SETTINGS TO LOCAL DRIVE c:\usmtmig\%Folder_Name%
echo .......................................................................

c:\usmt\scanstate.exe c:\usmtmig\%Folder_Name% /i:miguser.xml /i:migapp.xml /i:migsys.xml /ue:*\* /ui:sageukie\%Folder_Name% /localonly /o /c


pause:

:end
exit
Edited by SmOke_N

Share this post


Link to post
Share on other sites

Iain,

Welcome to the AutoIt forum. :huh2:

I am afraid that there is rather more to converting bat files to AutoIt code than just opening them in SciTE. You need to understand the syntax of AutoIt so you can replace the DOS commands with new ones. ;)

Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading. :alien:

You will find that there is no great difficulty in converting bat files to AutoIt code - once you have got the hang of it you will wonder what the problem was. But you do need to take a while to get to grips with the various functions first. Good luck - you know where we are if you get stuck! :)

M23

P.S. I have just seen your code - in future when you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code - it then appears in nice scrollable boxes. You cannot edit your posts until you have made a few more - I will ask a Mod to do it for you in this case. :ph34r:


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

M23,

Thanks for the informative reply mate! Appreciate it!! I will hit the help files and hopefully one day I will look back and think what the fuss was about haha.

Again, much appreciated.

Iain.

Share this post


Link to post
Share on other sites

To get you on your way have a look at Run(), StringInStr(), ConsoleWrite(), FileCopy(), DirCopy(), DirCreate() & DriveGetDrive() to name but a few. Good Luck!


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0