Jump to content

Adding Switches to Shortcutlink


Recommended Posts

Hi All,

I am new to AutoIT and can't believe I have missed this fantastic app on my frequent internet travels. I am currently making a frontend to run utilities for my mother who is disabled and finds using the keyboard hard but she can control the mouse fine.

As her programs are installed in different directories to mine I have made some shortcuts in the same directory as the script will be installed. What I want to do is for the script to interrogate the shortcut and add some commandline switches.

For instance I want to run spybot and add the following switches /autoupdate /autocheck /autofix /autoclose

I have already created the buttons etc and added this to the script:-

Func AdWarePressed()

$details = FileGetShortcut("Maintenance\spybotsd.lnk")

Run($details[0])

EndFunc

and put the command switches in the shortcut link, but the script does not read these and just starts spybot instead. I would appreciate a little help as I have nearly completed what I need to do.

Thanks

Adrian

Link to comment
Share on other sites

try

FileCreateShortCut("my\path\to\spybot\exe", 'my\path\to\the\shortut', '', "/autoupdate /autocheck /autofix /autoclose")
Func AdWarePressed()
$m = FileGetShortCut("my\path\to\the\shortcut.lnk")
run($m[0] & " " & $m[2])
endfunc

Just replac the "my\path\to\...." with the paths and that should work.

~cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

Thanks for the quick response, when I run the script I get this error:-

C:\Documents and Settings\Administrator\Desktop\Batch Scripts\Maintenance.au3 (73) : ==> Subscript used with non-Array variable.:

run($m[0] & " " & $m[2])

run($m^ ERROR

As I am very inexperienced I am not sure what this means.

Adrian

try

FileCreateShortCut("my\path\to\spybot\exe", 'my\path\to\the\shortut', '', "/autoupdate /autocheck /autofix /autoclose")
Func AdWarePressed()
$m = FileGetShortCut("my\path\to\the\shortcut.lnk")
run($m[0] & " " & $m[2])
endfunc

Just replac the "my\path\to\...." with the paths and that should work.

~cdkid

Link to comment
Share on other sites

Post your new code, please.

~cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

This is the script that I am working on, which I am currently building on my PC.

Thanks for your time

Adrian

; Script Start - Add your code below here

#include <GUIConstants.au3>

Opt("GUICoordMode",2)

Opt("GUIResizeMode", 1)

Opt("GUIOnEventMode", 1)

$parent1 = GUICreate("Maintenance", 500, 500)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")

GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

$defrag1 = GUICtrlCreateButton("Defrag Drive C", 200, 100, 100)

GUICtrlSetOnEvent(-1, "Defrag1Pressed")

$defrag2 = GUICtrlCreateButton("Defrag Drive D", -100, 25)

GUICtrlSetOnEvent(-1, "Defrag2Pressed")

$temp = GUICtrlCreateButton("Clean Out Temp Files", -135, 25, 175)

GUICtrlSetOnEvent(-1, "TempPressed")

$adware = GUICtrlCreateButton("Scan System for Adware", -175 , 25)

GuiCtrlSetOnEvent(-1, "AdwarePressed")

$pdefrag = GUICtrlCreateButton("Defrag Page File Requires Reboot", -175, 25)

GuiCtrlSetOnEvent(-1, "PdefragPressed")

$root = GUICtrlCreateButton("RootKit Scan", -175, 25)

GuiCtrlSetOnEvent(-1, "RootPressed")

$anti = GUICtrlCreateButton("Anti-Virus Scan", -175, 25)

GuiCtrlSetOnEvent(-1, "AntiPressed")

$exit = GUICtrlCreateButton("Exit", -175, 25)

GuiCtrlSetOnEvent(-1, "ExitPressed")

GUISetState(@SW_SHOW)

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

; END

Func Defrag1Pressed()

Run("Maintenance\Contig\Contig.exe -s -v C:\*.*")

EndFunc

Func Defrag2Pressed()

Run("Maintenance\Contig\Contig.exe -s -v D:\*.*")

EndFunc

Func TempPressed()

Run("Maintenance\DustBuster.exe")

EndFunc

Func AdWarePressed()

FileCreateShortCut("C:\Utilities\Anti-Virus\Spybot - Search & Destroy\spybotsd.exe", 'Batch Scripts\Maintenance\', '', "/autoupdate /autocheck /autofix /autoclose")

$m = FileGetShortCut("Maintenance\spybot.lnk")

run($m[0] & " " & $m[2])

EndFunc

Func PdefragPressed()

Run("Maintenance\PageDefrag\pagedfrg.exe -o -t10")

EndFunc

Func RootPressed()

Run("Maintenance\Rootkitrevealer\rootkitrevealer.exe -c -a C:\Log\root.log")

EndFunc

Func AntiPressed()

Run("Anti.exe")

EndFunc

Func ExitPressed()

Exit

EndFunc

Func SpecialEvents()

Select

Case @GUI_CTRLID = $GUI_EVENT_CLOSE

Exit

Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE

Case @GUI_CTRLID = $GUI_EVENT_RESTORE

EndSelect

EndFunc

Link to comment
Share on other sites

Any file names with spaces, use

$var = FileGetShortName("some file name with spaces.extension")

then do whatever with var

~cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

If your not opposed to context menus check out CMenu. It will allow you to provide command line params.

Link to comment
Share on other sites

Wow now I am really confused and feel I am out of my depth here, I have tried adding the first bit of code that you suggested Larry as that seems the most straight forward and it tells me:-

C:\Documents and Settings\Administrator\Desktop\Batch Scripts\Maintenance.au3 (72) : ==> Subscript used with non-Array variable.:

If StringInStr($details[0],"""") Then

If StringInStr($details^ ERROR

+>AutoIT3.exe ended.rc:0

I really am not sure where to go from here, but I am really impressed with the willingness of help on these forums.

Adrian

Link to comment
Share on other sites

Doh! Just realised why the script won't work, i have left one part the directory structure as 'Batch Scripts\Maintenance\', and not the full patch to the working directory.

Is there anyway of incorpating the @scriptdir command in $details = FileGetShortcut("Maintenance\spybotsd.lnk") as I am not sure which directory the script will be in.

Thanks

Adrian

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...