Jump to content


Photo

Help with passing variable to command?


  • Please log in to reply
1 reply to this topic

#1 twofish

twofish
  • Members
  • 17 posts

Posted 19 June 2012 - 06:01 PM

Trying to create an "admin tool" for my own use. Either an app is run with my regular user account or it's run with my domain admin account. I'll either run the tasks locally (such as powershell, cmd, specific citrix shortcuts, etc) or I'll run them by passing a remote host variable. I can't seem to figure out 2 things here:

1) Passing a variable (vgRhostEnt) captured in an Edit box
2) Mapping the C$ drive of %gRhostEnt% to z: in the command window with DOMAIN\AdminUser privileges, then delete when you exit from the command window.

Gui, Add, Text, x76 y10 w110 h30 +Center, Non-Admin Account
Gui, Add, Button, x16 y50 w70 h40 , CMD
Gui, Add, Button, x96 y50 w70 h40 , PowerShell
Gui, Add, Button, x176 y50 w70 h40 , KeePass

Gui, Add, Text, x76 y100 w110 h30 +Center, Admin Account
Gui, Add, Button, x16 y130 w70 h40 , Admin-CMD
Gui, Add, Button, x96 y130 w70 h40 , Admin-PS
Gui, Add, Button, x176 y130 w70 h40 , AD-Exch
Gui, Add, Button, x16 y180 w70 h40 , ITS
Gui, Add, Button, x176 y180 w70 h40 , CIT

Gui, Add, Text, x76 y260 w110 h30 +Center, Remote Host
Gui, Add, Edit, x16 y280 w230 h20 +Center vgRhostEnt,
Gui, Add, Button, x16 y320 w70 h40 , EventVwr
Gui, Add, Button, x96 y320 w70 h40 , MapCtoZ
Gui, Add, Button, x176 y320 w70 h40, RemoteDesk
; Generated using SmartGUI Creator 4.0
Gui, Show, x1204 y124 h378 w267, HCMC AHK Tool
Return

ButtonCMD:
Run, C:\WINDOWS\System32\cmd.exe
Return

ButtonPowerShell:
Run, C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe
Return

ButtonKeePass:
Run, "C:\Program Files\KeePass Password Safe 2\KeePass.exe"
Return

ButtonEP-CMD:
Run, runas /profile /user:DOMAIN\AdminUser "C:\WINDOWS\System32\cmd.exe", ,UseErrorLevel
Return

ButtonEP-PS:
Run, runas /profile /user:DOMAIN\AdminUser "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe", ,UseErrorLevel
Return

ButtonAD-Exch:
Run, runas /profile /user:HCMC\ep7712 "mmc %windir%\system32\ExchAD.msc", ,UseErrorLevel
Return

ButtonITS:
Run, 
"linkyhere"
Return

ButtonCIT:
Run, "Citrix Link"
Return

ButtonEventVwr:
GuiControl,Text,gRhostEnt 
Run, runas /profile /user:DOMAIN\AdminUser "eventvwr.exe %gRhostEnt%"
Return

ButtonMatCtoZ:
Run, runas /profile /user:DOMAIN\AdminUser "net use ??

ButtonRemoteDesk:
Run, "%SystemRoot%\system32\mstsc.exe /v:%gRhostEnt%"
Return

GuiEscape:
GuiClose:
ExitApp


#2 HotKeyIt

HotKeyIt
  • Fellows
  • 6190 posts

Posted 19 June 2012 - 07:51 PM

1. add following as the first line to your subroutine, this will write Gui values to variables.
Gui,SubMit,NoHide
2. Not sure about that one, probably you can use NET USE command in cmd.