2
1
Derivar 0

Location Agnostic Code

Este cometimento está contido em:
Josh Mudge 2019-11-09 17:14:39 -07:00
ascendente 33b2f36db5
cometimento 4b90f7f88f
1 ficheiros modificados com 12 adições e 7 eliminações

Ver ficheiro

@ -49,18 +49,23 @@ This will allow us to set the name of the program, version, etc. and most import
go-powershell go-powershell
``` ```
# working directory is dir import(
dir, err := os.Getwd() "os"
"fmt"
"log"
)
func main() {
dir, err := os.Getwd()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
``` ```
Might have to create another variable set to the string and add the path. ```
var dirs string = "New-NetFirewallRule -DisplayName 'Name of Rule' -Direction Inbound -Program '" + dir + "\\server.exe'"
```
```
# This command will create the firewall rule.
New-NetFirewallRule -DisplayName "Name of Rule" -Direction Inbound -Program "C:\path\to\app\file.exe" -Action Allow
```
You should see something like this: You should see something like this: