Jump to content
Sign in to follow this  
creamers

Multiple Variable Syntax and Variable getting changed for no reason.

Recommended Posts

creamers

Func backupmove()
_Take('all', GUICtrlRead($driveletter))
RunWait('./includes/tc/tcc.exe bckmove.bat ' & $driveletter & $dataloc, '', @SW_HIDE)
EndFunc ;==>Backup Move
I am having trouble passing multiple variables to a cmd prompt. TCC is a replacment CMD prompt that I am using in my script. I have been successfull in doing it with one variable but not two yet.

@echo off

REM %1 is the first argument taking the Source Folder, %2 is the second argument taking the destination folder path.

REM usuage bckmove H: "SvrShare$Customer %Date% $Technician"

robocopy %1 %2 /E /256 /MOVE /Z >> log.txt

I can use the cmd script just fine with regular arguments.

Can someone show an example of the correct syntax to pass the variables along?

Edited by creamers

Share this post


Link to post
Share on other sites
water

You have to add a space so TCC can "see" multiple parameters:

RunWait('./includes/tc/tcc.exe bckmove.bat ' & $driveletter & ' ' & $dataloc, '', @SW_HIDE)
Edited by water
  • Like 2

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
creamers

You have to add a space so TCC can "see" multiple parameters:

RunWait('./includes/tc/tcc.exe bckmove.bat ' & $driveletter & ' ' & $dataloc, '', @SW_HIDE)

That sample is not working. Robocopy is reporting

2013/08/21 13:57:44 ERROR 2 (0x00000002) Accessing Source Directory C:UsersWesleyDropboxSharedAuto It ScriptsBackup ScriptWesleyscript15

The system cannot find the file specified.

The function as it stands is

Func backupmove()
;_Take('all', GUICtrlRead($driveletter))
RunWait('./includes/tc/tcc.exe bckmove.bat ' & $driveletter & ' ' & $dataloc, '', @SW_HIDE)
EndFunc ;==>Backup Move

Then bckmove.bat is

@echo off

REM %1 is the first argument taking the Source Folder, %2 is the second argument taking the destination folder path.

REM usuage bckmove H: SvrShare$Customer %Date% $Technican

robocopy %1 %2 /E /COPY:DAT /256 /MOVE /Z /R:2 /W:0 /LOG+:log.txt

Again I can still run it by hand just fine which is the really odd part.

Oddly enough I tested the variable and somehow it is being reported as 15?

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=08-12-13.exe
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Copyright 2013 Wesley Kirkland & Brandon Hall
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#AutoIt3Wrapper_Res_File_Add=./includes
#AutoIt3Wrapper_Res_File_Add=./images
#AutoIt3Wrapper_Res_File_Add=ownership.bat
#AutoIt3Wrapper_Res_File_Add=permissions.bat
#AutoIt3Wrapper_Res_File_Add=symlinks.bat
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
#include <GuiButton.au3>
#include <GuiToolBar.au3>
#include <File.au3>
#include <IE.au3>

;File Install Section Only used for compiling!
FileInstall("C:\Users\Wesley\Dropbox\Photos\Desktops\home_is_where_the_hard_disk_is_by_beaucoupzero-d175fpx.jpg", "images\harddisk.jpg")

Func _mainscript()
EndFunc
#region ### START Koda GUI section ### Form=c:\users\wesley\desktop\backup script\koda\main interface.kxf
$Form1_1 = GUICreate("Computer Works Automated Backup Script", 598, 421, 192, 124)
$Pic1 = GUICtrlCreatePic("./images/harddisk.jpg", 0, 0, 612, 468)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("Computer Works Automated Backup", 0, 0, 391, 33)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
;Now were cooking bacon, Oh wait I mean buttons. Oh hell just bring me some damn food.
$viewerlogs = GUICtrlCreateButton("Log File", 520, 0, 75, 25)
$deletelogs = GUICtrlCreateButton("Delete Log", 420, 0, 95, 25)
;$selectfolder = GUICtrlCreateButton("Select Folder", 420, 30, 95, 25)
$makelog = GUICtrlCreateButton("Blank Log", 520, 30, 75, 25)
$Script = GUICtrlCreateProgress(376, 296, 150, 17)
$ownership = GUICtrlCreateButton("Step 1: Ownership", 8, 136, 115, 25)
$permissions = GUICtrlCreateButton("Step 2: Permissions", 8, 168, 115, 25)
$symlinks = GUICtrlCreateButton("Step 3: Symlinks", 8, 200, 115, 25)
$backupmove = GUICtrlCreateButton("Step 4: Backup Move", 8, 232, 115, 25)
$backupcopy = GUICtrlCreateButton("Step 4: Backup Copy", 8, 264, 115, 25)
;$Customer = GUICtrlCreateInput("Customer", 224, 216, 129, 21)
;$Technician = GUICtrlCreateInput("Technician", 224, 240, 70, 21)
$dataloc = GUICtrlCreateInput("Data Destination", 224, 216, 140, 21)
$driveletter = GUICtrlCreateInput("DriveLetter", 224, 264, 60, 21)
Dim $Form1_1_AccelTable[3][2] = [["^p", $permissions],["^!s", $symlinks],["^b", $backupmove]]
GUISetAccelerators($Form1_1_AccelTable)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

;This makes all the buttons work, I dont know why or how it just does.
While 1
$msg = GUIGetMsg()
If $msg = -3 Then Exit
If $msg = $viewerlogs Then viewerlogs()
If $msg = $ownership Then ownership()
If $msg = $permissions Then Permissions()
If $msg = $symlinks Then Symlinks()
If $msg = $deletelogs Then deletelogs()
If $msg = $makelog Then makelog()
If $msg = $backupmove then backupmove()
if $msg = $backupcopy then backupcopy()
;If $msg = $selectfolder Then selectfolder()

WEnd
# ;****This wil open tail to view the logfile. ****
Func viewerlogs()
If FileExists("./log.txt") Then ;****Checks to see if the log file exists****
Run("./includes/tail.exe -f log.txt") ;****Runs tail.exe if the log file was found to view the log file****

Else
MsgBox(0, "Error", "There is no log file") ;****if There is no log file displays "There is not log file***
EndIf
EndFunc ;==>viewerlogs


# ;****This will delete the logfile. ****
Func deletelogs()
If FileExists("./log.txt") Then ;****Checks to see if the log files exists*****
FileDelete("log.txt") ;****If the log file exits then it will attempt to delete it****
If FileExists("./log.txt") Then ;****Now we check to see if the file was actualy deleted****
MsgBox(0, "Oops", "Something went wrong") ;****If the file stil exists then display "Something went wrong"

Else
MsgBox(0, "File Deleted", "Log File Removed Successfully") ;****If the file does not exist then it was successfully and displays "Removed successfully"****
EndIf
Else
MsgBox(0, "Error", "There is no log file") ;****If there there was not log file originally displays "There is not log file"*****
EndIf

EndFunc ;==>deletelogs

Func makelog()
If FileExists("./log.txt") Then ;****Checks to see if the log file exists****
_FileCreate("log.txt") ;****Blanks the Log File****
MsgBox(0, "Blanking Log File", "The log file is empty now") ;**** Displays message that the log file is blank now****
Else
MsgBox(0, "Error", "There is no log file, I now made a blank one!") ;****if There is no log file displays "There is not log file***
_FileCreate("log.txt") ;****Creates a log file****
EndIf
EndFunc ;==>makelog

# ;****This will take ownership of the $driveletter drive. ****
Func ownership()
_Take('own', GUICtrlRead($driveletter))
EndFunc ;==>ownership

Func Permissions()
_Take('own', GUICtrlRead($driveletter))
_Take('permissions', GUICtrlRead($driveletter))
EndFunc ;==>Permissions

Func Symlinks()
_Take('all', GUICtrlRead($driveletter))
EndFunc ;==>Symlinks

Func backupmove()
;_Take('all', GUICtrlRead($driveletter))
MsgBox(0,"Shows the Vars", $driveletter)
;RunWait('./includes/tc/tcc.exe bckmove.bat ' & $driveletter & ' ' & $dataloc, '', @SW_HIDE)
EndFunc ;==>Backup Move

Func backupcopy()
_Take('all', GUICtrlRead($driveletter))
EndFunc ;==>Backup Copy

Func _Take($action, $driveletter)
Switch $action
;**** Ownership /All Case
Case 'own', 'all'
MsgBox(0, "Starting", "Starting Ownership on " & $driveletter, 3)
RunWait('./includes/tc/tcc.exe ownership.bat ' & $driveletter, '', @SW_HIDE)
If $driveletter = "DriveLetter" Then
MsgBox(0, "Drive does not Exist!", "ID10T error detected! This point is null and void! User Must be replaced to continue the requested action.")
Else
MsgBox(0, "Ownership Taken", "Ownership has been taken on " & $driveletter, 3)
EndIf
If $action = 'all' Then ContinueCase

;**** Permissions Case
Case 'permissions'
MsgBox(0, "Starting", "Starting Permissions on " & $driveletter, 3)
RunWait('./includes/tc/tcc.exe permissions.bat ' & $driveletter, '', @SW_HIDE)
If $driveletter = "DriveLetter" Then
MsgBox(0, "Drive does not Exist!", "ID10T error detected! This point is null and void!")
Else
MsgBox(0, "Almost Done!", "Ownership, and permissions have all been ACL set! on " & $driveletter, 3)
EndIf
If $action = 'all' Then ContinueCase
;**** Symlinks Case
Case 'symlinks'
RunWait('./includes/tc/tcc.exe symlinks.bat ' & $driveletter, '', @SW_HIDE)
MsgBox(0, "Done!", "Ownership, permissions, and symlinks have all been removed! on " & $driveletter, 3)
Case Else
Return SetError(1, 0, 0)
EndSwitch
EndFunc ;==>_Take

I stored the variable to another variable before it was touch right after it was declared and it still shows 15? This is really odd.

Share this post


Link to post
Share on other sites
BrewManNH

Look at GUICtrlRead, you're doing it wrong.

  • Like 1

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
creamers

Look at GUICtrlRead, you're doing it wrong.

Ah thank you very much. Brain fart much. It is fixed now. :)

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  

×