elfreaks Posted May 4, 2013 Share Posted May 4, 2013 i made a little script for run a programs at my PC when i try to run this script i get this error Line 22 (File) If (computername = "Zief") { If (computername = "Zief") ^ERROR Unable to parse line. If (computername = "Zief") { Run, C:\Program Files (x86)\TeamViewer\Version7\TeamViewer.exe } And Anyone can give me script for get pnpdeviceid? like this script? expandcollapse popupFunc _getpnpdeviceid($drive, $fullid = 0) $objwmiservice = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2") If NOT IsObj($objwmiservice) Then Return - 1 $coldevice = $objwmiservice.execquery("SELECT * from Win32_LogicalDiskToPartition") $var = "" For $objitem In $coldevice If StringInStr($objitem.dependent, $drive) Then $var = StringTrimLeft($objitem.antecedent, StringInStr($objitem.antecedent, "=")) EndIf Next If NOT $var Then Return - 2 $coldevice = $objwmiservice.execquery("SELECT * from Win32_DiskDriveToDiskPartition") $diskpartition = $var $var = "" For $objitem In $coldevice If StringInStr($objitem.dependent, $diskpartition) Then $var = StringTrimLeft($objitem.antecedent, StringInStr($objitem.antecedent, "=")) EndIf Next If NOT $var Then Return - 3 $coldevice = $objwmiservice.execquery("SELECT * from Win32_DiskDrive") $physicaldrive = StringReplace(StringReplace($var, "\\", "\"), '"', "") $var = "" For $objitem In $coldevice If $objitem.deviceid = $physicaldrive Then $var = $objitem.pnpdeviceid EndIf Next If NOT $var Then Return - 4 If NOT $fullid Then $var = StringTrimLeft($var, StringInStr($var, "\", 0, -1)) Return $var EndFunc If $id <> "ID" Then Exit Else EndIf i try to add this script but i always get error i want to add this script into my progams and make my programs cannot run into different PC Link to comment Share on other sites More sharing options...
mikell Posted May 4, 2013 Share Posted May 4, 2013 (edited) ; Msgbox(0,"", @computername ) Msgbox(0,"", _GetPnpDeviceId("C:", 0) ) Func _GetPnpDeviceId($drive, $fullID = 0) Dim $Services = ObjGet('winmgmts:\\.\root\cimv2') Dim $DiskDrives = $Services.ExecQuery("Select DeviceID, PNPDeviceID From Win32_DiskDrive") For $DiskDrive In $DiskDrives Dim $DiskPartitions = $Services.ExecQuery("Associators of {Win32_DiskDrive.DeviceID='" & _ $DiskDrive.DeviceID & "'} Where AssocClass = Win32_DiskDriveToDiskPartition") For $DiskPartition In $DiskPartitions Dim $LogicalDisks = $Services.ExecQuery ("Associators of {Win32_DiskPartition.DeviceID='" & _ $DiskPartition.DeviceID & "'} Where AssocClass = Win32_LogicalDiskToPartition") For $LogicalDisk In $LogicalDisks If $LogicalDisk.DeviceID = $drive Then $Id = $DiskDrive.PnpDeviceId If not $fullID Then Return StringRegExpReplace($Id, '.+\\(.+?)', "$1") Else Return $Id EndIf EndIf Next Next Next EndFunc Edited May 4, 2013 by mikell Link to comment Share on other sites More sharing options...
Nessie Posted May 4, 2013 Share Posted May 4, 2013 Tested and working: expandcollapse popupIf @ComputerName = "Zief" Then Run("C:\Program Files (x86)\TeamViewer\Version7\TeamViewer.exe") EndIf MsgBox(0, "PNP DEVICE ID", _GetPNPDeviceID("C:", 0)) Func _GetPNPDeviceID($drive, $fullid = 0) $objWMIService = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2") If Not IsObj($objWMIService) Then Return -1 ;Failed to Connect to WMI on Local Machine $colDevice = $objWMIService.ExecQuery("SELECT * from Win32_LogicalDiskToPartition") $var = "" For $objItem In $colDevice If StringInStr($objItem.Dependent, $drive) Then $var = StringTrimLeft($objItem.Antecedent, StringInStr($objItem.Antecedent, "=")) EndIf Next If Not $var Then Return -2 ;Failed to Find Drive Letter $colDevice = $objWMIService.ExecQuery("SELECT * from Win32_DiskDriveToDiskPartition") $diskpartition = $var $var = "" For $objItem In $colDevice If StringInStr($objItem.Dependent, $diskpartition) Then $var = StringTrimLeft($objItem.Antecedent, StringInStr($objItem.Antecedent, "=")) EndIf Next If Not $var Then Return -3 ;Failed to Find Physical Drive # $colDevice = $objWMIService.ExecQuery("SELECT * from Win32_DiskDrive") $physicaldrive = StringReplace(StringReplace($var, "\\", "\"), '"', "") $var = "" For $objItem In $colDevice If $objItem.DeviceID = $physicaldrive Then $var = $objItem.PNPDeviceID EndIf Next If Not $var Then Return -4 ;Failed to Find PNPDeviceID If Not $fullid Then $var = StringTrimLeft($var, StringInStr($var, "\", 0, -1)) ;Return Ugly Full PNPDeviceID Return $var EndFunc ;==>_GetPNPDeviceID Hi! My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file Link to comment Share on other sites More sharing options...
wisem2540 Posted May 4, 2013 Share Posted May 4, 2013 (edited) If you want to make it so that your apps to do not run on different PCs, look at @computername For example If @computername = "MyComputerName" Then ;Script here Else Msgbox (0, "test", "This is not the correct computer") exit Endif Edited May 4, 2013 by wisem2540 Link to comment Share on other sites More sharing options...
spudw2k Posted May 4, 2013 Share Posted May 4, 2013 (edited) Boy that _GetPNPDeviceID() code looks familiar...... Edited May 4, 2013 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now