Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

vbs launching

$
0
0
I would never claim to be great at AutoIt but will Google and tinker until I get my script working.
Today after 5 hours of frusteration I finally created an account on this awesome board for help...

I need to launch a vbs file with a modifier (not sure if that's the right terminology).
From the run command when I put CopyMembership.vbs "username1" "username2" it runs the vbs which references the 2 provided usernames.
The only way I can incorporate running this script is popping open a Run Window and 'send'ing the complied text and running.
It's tacky and I'd like to Run/Shell Execute it.
Here's the code that works but is ugly:
FileCopy ("\\Shcsd.sharp.com\sharp\soc\groups\ISD Common\.TemporaryItems\CopyMembership.vbs", "C:\Temp\")
Sleep (2000)
Local $CopiedFrom = InputBox ( "Membership Copy", "Please enter the username of the user you are copying FROM", "", "")
Local $CopyTo = InputBox ( "Membership Copy", "Please enter the username of the user you are copying TO", "", "")
$OKorCancel = MsgBox ( 1, "Please verify", $CopyTo &" will get " & $CopiedFrom & "'s groups" )
Switch $OKorCancel
   Case 2
   FileDelete ("C:\Temp\CopyMembership.vbs")
   MsgBox (16, "HALT!", "Cancelled by user")
   Exit
   Case 1
   Send ( "#r" )
   WinWait ("Run")
   Sleep (300)
   Send ("C:\Temp\CopyMembership.vbs " &'"' &$CopiedFrom & '" ' &'"' &$CopyTo &'"')
   Send ("{TAB}{ENTER}")
   Exit
EndSwitch
Exit


I would love to have something like:
FileCopy ("\\Shcsd.sharp.com\sharp\soc\groups\ISD Common\.TemporaryItems\CopyMembership.vbs", "C:\Temp\")
Sleep (2000)
Local $CopiedFrom = InputBox ( "Membership Copy", "Please enter the username of the user you are copying FROM", "", "")
Local $CopyTo = InputBox ( "Membership Copy", "Please enter the username of the user you are copying TO", "", "")
$OKorCancel = MsgBox ( 1, "Please verify", $CopyTo &" will get " & $CopiedFrom & "'s groups" )
Switch $OKorCancel
   Case 2
   FileDelete ("C:\Temp\CopyMembership.vbs")
   MsgBox (16, "HALT!", "Cancelled by user")
   Exit
   Case 1
   ShellExecute ("C:\Temp\CopyMembership.vbs " &'"' &$CopiedFrom & '" ' &'"' &$CopyTo &'"')
   Exit
EndSwitch
Exit


I even tried compiling the path into a variable with no launching luck (the notepad is just for troubleshooting and verification of the path being legit)
FileCopy ("\\Shcsd.sharp.com\sharp\soc\groups\ISD Common\.TemporaryItems\CopyMembership.vbs", "C:\Temp\")
Local $CopiedFrom = "polzo"
Local $CopyTo = "polza"
Local $Path = "C:\Temp\CopyMembership.vbs " &'"' &$CopiedFrom & '" ' &'"' &$CopyTo &'"'
WinActivate ("Untitled - Notepad")
Send ($Path)
Sleep (2000)
Send ("{SHIFTDOWN}{HOME}{SHIFTUP}")
Sleep (200)
Send ("{DEL}")
ShellExecute ($Path)
;or something like that, I've tried dozens of combinations
Exit


This may be a case where I don't know the terminology or maybe a limitation?
Thanks a gazillion in advance for any help in advance and I apoligize if my code is yucky,
Mike

Viewing all articles
Browse latest Browse all 12506

Trending Articles