Jump to content

excluding certain computers with @computername macro


Recommended Posts

Hi there, 

Im working on trying to exclude one computer from getting a file to run when a user logs onto it. I cant seem to figure out how to properly create a function to do this. What am I missing to get the .exe to not run if a user signs into a specific computer? 

 

Func testfunction()
   if (@ComputerName <> "computer1") Then
      Run(@ComSpec & " /c " & "\\server\directory\program.exe","", @SW_HIDE)
   ElseIf (@ComputerName = "computer1") then Exit
   EndIf

EndFunc

 

Link to comment
Share on other sites

How many computers do you have? Maybe make an array with all the computer names you want to run the program on, and not include the ones you don't want.

 

#Include <Array.au3>

Global $Comp_List['computer2', 'computer3', 'computer4', ...etc]

Func testfunction()
   For $i = 1 to Ubound($Comp_List) - 1
      Run(@ComSpec & " /c " & "\\server\directory\program.exe","", @SW_HIDE) ; Not sure where you input the computer name in this command line.
      ; For the computer name do this wherever it is you put it. $Comp_List[$i]
   Next

EndFunc

 

Edited by FengHuangWuShen
Link to comment
Share on other sites

Hi there, I only have one computer Computer1 in this case that i need to exclude. I would just need the login script to check if a user is logging ionto computer1 to block the installation of that one specific file. 

I could however use an array to exclude that machine but how would i get the login script to close the program if a user is logging onto that specific computer im trying to block file access to?

Link to comment
Share on other sites

Thank you for your help, however i still need help trying to get this to work. 
the while loop is a good idea and taskkill will solve killing the application in question on the one machine. However I still need the application to run on every other machine but computer1. That;s why I had thought of using the crude if,elseif statement up at the top. 

i am using the AD scriptlets, but I cannot seem to get this to work properly: 
 

#include <AD.au3>

func testfunction()
_AD_Open()

If _AD_IsMemberOf("included computers") then
   Run(@ComSpec & " /c " & "\\server\directory\program.exe","", @SW_HIDE)

   ElseIf _AD_IsMemberOf("excluded computers") then 
       Run('taskkill /IM program.exe /F')
   EndIf

    _AD_Close()
EndFunc

What am i missing to kill the software from starting on the excluded computer ( just one computer)

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...