<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Tool-Windows on GousterCloud</title>
    <link>https://wangmin362.github.io/tags/tool-windows/</link>
    <description>Recent content in Tool-Windows on GousterCloud</description>
    <image>
      <title>GousterCloud</title>
      <url>https://wangmin362.github.io/images/papermod-cover.png</url>
      <link>https://wangmin362.github.io/images/papermod-cover.png</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <language>zh</language>
    <lastBuildDate>Sun, 24 Mar 2024 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://wangmin362.github.io/tags/tool-windows/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Windows自定义后台进程并设置为开机启动</title>
      <link>https://wangmin362.github.io/posts/tools/windows/01.windows%E8%87%AA%E5%AE%9A%E4%B9%89%E5%90%8E%E5%8F%B0%E8%BF%9B%E7%A8%8B%E5%B9%B6%E8%AE%BE%E7%BD%AE%E4%B8%BA%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8/</link>
      <pubDate>Sun, 24 Mar 2024 00:00:00 +0000</pubDate>
      <guid>https://wangmin362.github.io/posts/tools/windows/01.windows%E8%87%AA%E5%AE%9A%E4%B9%89%E5%90%8E%E5%8F%B0%E8%BF%9B%E7%A8%8B%E5%B9%B6%E8%AE%BE%E7%BD%AE%E4%B8%BA%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8/</guid>
      <description>1 背景 自己开发了一个应用程序，想要再windows上后台运行，并且能够设置为开机启动。
2 目标 可以在Windows上配置任意一个可执行文件后台启动，并且设置为开机启动。
3 应用程序测试代码 测试代码非常简单，就是再运行之后，每隔三秒钟在可执行文件的同级目录的app-logs文件夹中创建文件。如果程序正常运行，那么我们就可以看到新创建的文件。
编译命令：go build -o app.exe main.go
package main import ( &amp;#34;fmt&amp;#34; &amp;#34;os&amp;#34; &amp;#34;time&amp;#34; ) func main() { dir := &amp;#34;app-logs&amp;#34; if err := os.MkdirAll(dir, os.ModePerm); err != nil { fmt.Printf(&amp;#34;%s\n&amp;#34;, err) os.Exit(1) } for { file := fmt.Sprintf(&amp;#34;.\\%s\\app测试_%s.txt&amp;#34;, dir, time.Now().Format(&amp;#34;2006.01.02_15_04_05&amp;#34;)) _, err := os.Create(file) if err != nil { os.Exit(1) } time.Sleep(3 * time.Second) } } 4 解决方案 4.1 方案一 使用sc命令注册服务（不推荐） 4.1.1 相关命令 ⚠注意：这些命令的执行需要以管理员的方式打开CMD</description>
    </item>
  </channel>
</rss>
